<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: adelinealmanzar</title>
    <description>The latest articles on DEV Community by adelinealmanzar (@adelinealmanzar).</description>
    <link>https://dev.to/adelinealmanzar</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F808289%2Ff1a99f63-3bfc-4742-aa1e-22b88dc6c256.png</url>
      <title>DEV Community: adelinealmanzar</title>
      <link>https://dev.to/adelinealmanzar</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/adelinealmanzar"/>
    <language>en</language>
    <item>
      <title>Build Your First Mobile App Using React Native and Expo</title>
      <dc:creator>adelinealmanzar</dc:creator>
      <pubDate>Thu, 21 Apr 2022 20:05:05 +0000</pubDate>
      <link>https://dev.to/adelinealmanzar/build-your-first-mobile-app-using-react-native-and-expo-3a18</link>
      <guid>https://dev.to/adelinealmanzar/build-your-first-mobile-app-using-react-native-and-expo-3a18</guid>
      <description>&lt;p&gt;&lt;strong&gt;React Native&lt;/strong&gt; is an open source framework used to make applications for mobile, specifically Android, Android TV, iOS, macOS, tvOS, Web, Windows and UWP.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Expo&lt;/strong&gt; is a framework for React Native that helps us create the skeleton of our application and view our application’s progress.&lt;/p&gt;

&lt;p&gt;To get our React Native application started, we need to create a project with Expo!&lt;/p&gt;

&lt;h3&gt;
  
  
  &lt;strong&gt;Setup our React Native App Using Expo&lt;/strong&gt;
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;To setup expo, we would run

&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;npm install --global expo-cli&lt;/code&gt; to install expo globally&lt;/li&gt;
&lt;li&gt;we would then run &lt;code&gt;npm init project-name&lt;/code&gt; to create our React Native project within the current directory (similar to &lt;code&gt;create-react-app&lt;/code&gt;)&lt;/li&gt;
&lt;li&gt;the previous init command will prompt us, in the terminal, to choose the type of template workflow we’d prefer (folks typically go with &lt;code&gt;blank&lt;/code&gt; on their first app if building from scratch)&lt;/li&gt;
&lt;/ul&gt;


&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Now that we have our project directory created, we can start our frontend server so we can view our application as we code.&lt;/p&gt;

&lt;h3&gt;
  
  
  &lt;strong&gt;Start our Client Server&lt;/strong&gt;
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;to start our client side server, we would cd into our project’s directory and run &lt;code&gt;npm start&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;this start command will automatically open up the devtools in our browser and start Expo’s Metro Bundler on a local port. To open a preview of our application, we can either:

&lt;ul&gt;
&lt;li&gt;open the Expo Go application on our mobile device by scanning the QR code that appears in the browser&lt;/li&gt;
&lt;li&gt;OR we can run our preferred simulator (using &lt;code&gt;i&lt;/code&gt; for ios or &lt;code&gt;a&lt;/code&gt; for android). If we’d like to view a preview of our frontend application within a simulator, we would need to install XCode first.&lt;/li&gt;
&lt;/ul&gt;


&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Here’s where the fun begins! Now we get to code in React Native!&lt;/p&gt;

&lt;h3&gt;
  
  
  &lt;strong&gt;Code in React Native&lt;/strong&gt;
&lt;/h3&gt;

&lt;p&gt;React Native provides core components, which are pre-built components with mobile optimization. Below are a few starter core components and APIs, which may be useful for when building our first React Native application and getting a feel for this framework if we’ve never used it before.&lt;/p&gt;

&lt;h4&gt;
  
  
  &lt;strong&gt;Helpful&lt;/strong&gt; &lt;strong&gt;Starter Core Components&lt;/strong&gt;
&lt;/h4&gt;

&lt;p&gt;&lt;strong&gt;&lt;code&gt;View&lt;/code&gt;&lt;/strong&gt; the view component is the most fundamental React Native component that acts as a container with flexbox, style, some touch handling, and accessibility controls. The &lt;code&gt;View&lt;/code&gt; in React Native is the mobile equivalent to &lt;code&gt;&amp;lt;div&amp;gt;&lt;/code&gt; in JSX or HTML.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;code&gt;Text&lt;/code&gt;&lt;/strong&gt; the text component in React Native is for displaying text. It is equivalent to JSX or HTML relative text tags, such as &lt;code&gt;&amp;lt;small&amp;gt;&lt;/code&gt;, or header tags, such as &lt;code&gt;&amp;lt;h1&amp;gt;&lt;/code&gt;, &lt;code&gt;&amp;lt;h2&amp;gt;&lt;/code&gt;, &lt;code&gt;&amp;lt;h3&amp;gt;&lt;/code&gt;, or paragraph tags, such as &lt;code&gt;&amp;lt;p&amp;gt;&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;code&gt;Image&lt;/code&gt;&lt;/strong&gt; is a component that displays different types of images. This component is similar to the &lt;code&gt;&amp;lt;img&amp;gt;&lt;/code&gt; tag in JSX or HTML.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;code&gt;ImageBackground&lt;/code&gt;&lt;/strong&gt; is a component that acts similarly to the &lt;code&gt;Image&lt;/code&gt; component and it allows any children components to be layered on top of it self. This component is the React Native equivalent to using a &lt;code&gt;background-image&lt;/code&gt; or &lt;code&gt;backgroundImage&lt;/code&gt; property within the styling of a custom JSX component.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;code&gt;TextInput&lt;/code&gt;&lt;/strong&gt; is a component that allows users to input text into the application via a keyboard, which (when using on a mobile application) usually slides on screen. The &lt;code&gt;TextInput&lt;/code&gt; props allow for configurability of auto-correction, capitalization, placeholder text, and different keyboard types. To read and create a call back function based on a user’s input, we would use the &lt;code&gt;onChangeText&lt;/code&gt; event.&lt;/p&gt;

&lt;p&gt;Additionally, there are other types of &lt;code&gt;TextInput&lt;/code&gt; events as well, such as &lt;code&gt;onSubmitEditing&lt;/code&gt; (which elicits a callback function when the submit button is pressed) and &lt;code&gt;onFocus&lt;/code&gt; (which blurs texts, such as when inputting a password). &lt;code&gt;TextInput&lt;/code&gt; and its event handler props are similar JSX forms, which usually use the &lt;code&gt;&amp;lt;form&amp;gt;&lt;/code&gt;, &lt;code&gt;&amp;lt;input&amp;gt;&lt;/code&gt;, and &lt;code&gt;&amp;lt;label&amp;gt;&lt;/code&gt; tags along with the &lt;code&gt;onSubmit&lt;/code&gt; event.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;code&gt;ScrollView&lt;/code&gt;&lt;/strong&gt; or &lt;strong&gt;&lt;code&gt;FlatList&lt;/code&gt;&lt;/strong&gt; are components that enable viewing children components via screen scrolling capabilities with a touch locking ‘responder’ system. &lt;code&gt;ScrollView&lt;/code&gt; loads all of its children components on first render, so if we have a bunch of child components that need to load at once we would see a performance downside. &lt;code&gt;FlatList&lt;/code&gt; improves this performance downside by loading its children components ‘lazily’, when the children are about to appear on the screen as the user is scrolling.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;code&gt;Button&lt;/code&gt;&lt;/strong&gt; or &lt;strong&gt;&lt;code&gt;Pressable&lt;/code&gt;&lt;/strong&gt; are components that enable event handlers via user interactivity. &lt;code&gt;Button&lt;/code&gt; is a simple component that acts as a button and supports minimal levels of customization. The &lt;code&gt;Pressable&lt;/code&gt; component allows for more complex customization as well as more complex user interactions with itself and its children components.&lt;/p&gt;

&lt;p&gt;React Native also offers other types of interactive pre-built components depending on what we need for our app. Some notable mentions are &lt;code&gt;TouchableOpacity&lt;/code&gt;, which dims the opacity of its wrapped &lt;code&gt;View&lt;/code&gt; on press down, and &lt;code&gt;TouchableWithoutFeedback&lt;/code&gt;, which allows for pressing anywhere within its singular &lt;code&gt;View&lt;/code&gt; child. Although there are warnings in the documentation to avoid using &lt;code&gt;TouchableWithoutFeedback&lt;/code&gt; unless we have a good reason, this component is cool because it can be used for user presses anywhere on screen (useful for games).&lt;/p&gt;

&lt;p&gt;These touchable components are similar to using the &lt;code&gt;&amp;lt;button&amp;gt;&lt;/code&gt; tag or the&lt;code&gt;&amp;lt;input&amp;gt;&lt;/code&gt; tag with a &lt;code&gt;submit&lt;/code&gt; type in JSX or HTML.&lt;/p&gt;

&lt;h4&gt;
  
  
  &lt;strong&gt;Some Useful APIs&lt;/strong&gt;
&lt;/h4&gt;

&lt;p&gt;&lt;strong&gt;&lt;code&gt;StyleSheet&lt;/code&gt;&lt;/strong&gt; is an abstraction that is similar to CSS StyleSheets, almost like ReactJS styled components and inline styling mixed together. This component is pretty cool because it supports reusability in allowing for pre-defined variables within its style values.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;code&gt;Dimensions&lt;/code&gt;&lt;/strong&gt; is an API that allows us to get the height and width of the currently used window. For developing in mobile, this API is extremely useful if we want to develop dynamically-styled components that render well on sorts of different of mobile devices and screen sizes.&lt;/p&gt;

&lt;h3&gt;
  
  
  Additional Components
&lt;/h3&gt;

&lt;p&gt;These components mentioned are just some of the most fundamental and most used components, but React Native offers a plethora of pre-built core &lt;a href="https://reactnative.dev/docs/components-and-apis"&gt;components and APIs&lt;/a&gt;. In addition, the community also offers a bunch of &lt;a href="https://js.coach/?collection=React+Native"&gt;custom pre-built React Native components&lt;/a&gt; for whatever use case we may need!&lt;/p&gt;

&lt;h4&gt;
  
  
  Resources
&lt;/h4&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href="https://reactnative.dev/docs/components-and-apis"&gt;React Native Core Components documentation&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://docs.expo.dev/"&gt;Expo documentation&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

</description>
      <category>reactnative</category>
      <category>react</category>
      <category>expo</category>
      <category>beginners</category>
    </item>
    <item>
      <title>Common Git Mistake Fixes</title>
      <dc:creator>adelinealmanzar</dc:creator>
      <pubDate>Tue, 05 Apr 2022 21:01:38 +0000</pubDate>
      <link>https://dev.to/adelinealmanzar/common-git-mistake-fixes-56ac</link>
      <guid>https://dev.to/adelinealmanzar/common-git-mistake-fixes-56ac</guid>
      <description>&lt;p&gt;Everybody makes mistakes and everybody has those days &lt;em&gt;especially when it comes to git&lt;/em&gt;, so here is a summary of solutions to common git errors (although of course there may be many approaches).&lt;/p&gt;

&lt;h4&gt;
  
  
  Circumstance: Made code changes and/or staged changes before creating a new branch
&lt;/h4&gt;

&lt;ul&gt;
&lt;li&gt;we either made changes to our code or made changes &lt;em&gt;and&lt;/em&gt; staged those changes to our index while in a wrong branch&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;If we made changes to our code before branching off of our starter branch (for ex: main/master) or we made changes &lt;em&gt;and&lt;/em&gt; staged those changes, we can run &lt;code&gt;git status&lt;/code&gt; to check which files contain changes.&lt;/p&gt;

&lt;p&gt;Since we haven’t committed our changes to our current wrong branch’s history yet, we can simply run &lt;code&gt;git checkout -b new_branch_name&lt;/code&gt; and our changes (staged or not) will follow us to whichever new branch we just created. From our new branch, we can then add and commit our changes to this new branch’s git history.&lt;/p&gt;

&lt;p&gt;We’ve tackled a slip up for when we’ve been wanting to create a new branch; but, if we want to move our changes to a pre-existing branch, we would need to follow some kind of stashing workflow.&lt;/p&gt;

&lt;h4&gt;
  
  
  Circumstance: Made code changes and/or staged changes before checking out a pre-existing branch
&lt;/h4&gt;

&lt;ul&gt;
&lt;li&gt;we made changes to our code and forgot to checkout a pre-existing branch&lt;/li&gt;
&lt;li&gt;we may have added/staged our changes as well&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;If we made code changes in the wrong branch but those changes haven’t been committed yet, we can use a &lt;code&gt;git stash&lt;/code&gt; workflow to shelve/stash our changes before we checkout the proper pre-existing branch.&lt;/p&gt;

&lt;h5&gt;
  
  
  &lt;code&gt;git stash&lt;/code&gt; Workflow
&lt;/h5&gt;

&lt;p&gt;When running &lt;code&gt;git status&lt;/code&gt; we can view which file changes we would like to be taking with us to the proper branch. Then, we can run &lt;code&gt;git stash&lt;/code&gt;, which will stash/shelve all of our current changes (whether added/staged or not). After stashing, we can checkout the pre-existing proper branch with &lt;code&gt;git checkout &amp;lt;correct_branch&amp;gt;&lt;/code&gt;. Once we’re in the proper branch, we can run &lt;code&gt;git stash pop&lt;/code&gt; to pop all of our changes out of the stash/shelf. After popping, we would be able to continue our usual &lt;code&gt;git add&lt;/code&gt; and &lt;code&gt;git commit&lt;/code&gt; workflow to add and commit those changes to the proper branch.&lt;/p&gt;

&lt;p&gt;Note that if we had changes staged &lt;em&gt;before our stash&lt;/em&gt; and we later popped our stashes, those staged changes would be un-staged on-pop automatically.&lt;/p&gt;

&lt;p&gt;So the full workflow would look like:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;git status&lt;/code&gt; to check which changes we would be stashing&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;git stash&lt;/code&gt; to stash/shelf all of our changes&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;git checkout &amp;lt;branch&amp;gt;&lt;/code&gt; to checkout the proper branch&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;git stash pop&lt;/code&gt; to remove the most recent stash from our shelf and track those changes in our proper branch&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;git add&lt;/code&gt; &amp;amp; &lt;code&gt;git commit&lt;/code&gt; workflow to add/stage and commit specific files to our proper branch’s history&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;If we altogether committed in the wrong branch, we can use a resetting workflow.&lt;/p&gt;

&lt;h4&gt;
  
  
  Circumstance: Committed in the wrong branch
&lt;/h4&gt;

&lt;ul&gt;
&lt;li&gt;we made changes to the code&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;git add .&lt;/code&gt; we staged all of our work&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;git commit -m "my first commit!"&lt;/code&gt; we committed our work&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;git branch&lt;/code&gt; we check our branch and OH NO! We realize we were in the wrong branch all along&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;If we added and committed our changes to the wrong branch locally, we could always rollback however many commits we need and move our un-staged changes into a new branch.&lt;/p&gt;

&lt;p&gt;First, we would run &lt;code&gt;git log&lt;/code&gt; to check our commit history and view how many commits we would like to undo.&lt;/p&gt;

&lt;p&gt;Then, we would run  &lt;code&gt;git reset HEAD~N&lt;/code&gt; where &lt;code&gt;N&lt;/code&gt; is the number of our commits to undo.&lt;/p&gt;

&lt;p&gt;If we do &lt;code&gt;git log&lt;/code&gt; again, we can see that our commits are no longer in the history of the current wrong branch. When we do &lt;code&gt;git status&lt;/code&gt;, we can also sanity check that the changes have been tracked and are ready to be staged.&lt;/p&gt;

&lt;p&gt;Because we would be checking out a new branch, we can simply run &lt;code&gt;git checkout -b new-correct-branch&lt;/code&gt; where &lt;code&gt;new-correct-branch&lt;/code&gt; is the new branch we wish to track, stage, and commit our changes in. Note: if were checking out a pre-existing branch, we would probably need to run our &lt;code&gt;git stash&lt;/code&gt; workflow to move our changes to the proper pre-existing branch.&lt;/p&gt;

&lt;p&gt;Once we’re in our &lt;code&gt;new-correct-branch&lt;/code&gt;, we can run &lt;code&gt;git add &amp;lt;paths-for-files-we-wish-to-add&amp;gt;&lt;/code&gt; (or we can also run &lt;code&gt;git add .&lt;/code&gt; to add &lt;em&gt;all&lt;/em&gt; of our changes that appear when we run &lt;code&gt;git status&lt;/code&gt;). And then we can run our &lt;code&gt;git commit -m "insert commit message here"&lt;/code&gt; to finally commit our changes to the proper branch.&lt;/p&gt;

&lt;p&gt;If we run &lt;code&gt;git log&lt;/code&gt;, we should see the proper commit history in our proper branch.&lt;/p&gt;

&lt;p&gt;So overall the workflow would look like so:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;git log&lt;/code&gt; to check our commit history to determine the number of commits we would like to roll back&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;git reset HEAD~N&lt;/code&gt; to reset the head of our current wrong branch back by our previously determined N number commits&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;git log&lt;/code&gt; to sanity check that our commit history no longer contains the wrong commits&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;git status&lt;/code&gt; to sanity check that our changes are being tracked and ready to move with us to whichever branch we checkout&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;git checkout -b new-correct-branch&lt;/code&gt; to create and move into our new proper branch that will store our accurate commit history&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;git add &amp;lt;file-paths&amp;gt;&lt;/code&gt; to stage our desired files&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;git commit -m "insert commit message here"&lt;/code&gt; to commit our changes to the proper branch history&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;git log&lt;/code&gt; to sanity check our current proper branch’s commit history&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Sometimes our mistakes aren't related to where our changes were made. Sometimes we pulled down the wrong branch altogether, so then what?&lt;/p&gt;

&lt;h4&gt;
  
  
  Circumstance: Pulled the down the wrong branch
&lt;/h4&gt;

&lt;ul&gt;
&lt;li&gt;thinking we’re in branch1, we &lt;code&gt;git pull origin branch2&lt;/code&gt; and OH NO! We realize we pulled down the wrong branch from the remote to our local branch&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;If we pull down the wrong remote branch to our local branch, we can always run a hard reset of the current branch with &lt;code&gt;git reset --hard origin/current_branch&lt;/code&gt;. Note of caution: &lt;code&gt;reset --hard&lt;/code&gt; is destructive in nature, so it will remove all staged and un-staged changes to overwrite the current local branch.&lt;/p&gt;

&lt;p&gt;If we want to save our changes &lt;em&gt;somewhere&lt;/em&gt; before we do a hard reset of the branch, we can use the &lt;code&gt;git stash&lt;/code&gt; workflow mentioned above.&lt;/p&gt;

&lt;h4&gt;
  
  
  TLDR:
&lt;/h4&gt;

&lt;ul&gt;
&lt;li&gt;We shouldn’t get into the habit of making mistakes, but there are ways to fix them&lt;/li&gt;
&lt;li&gt;We can always checkout a new branch if we’ve made staged or un-staged changes in a wrong branch as long as we don’t commit those changes yet&lt;/li&gt;
&lt;li&gt;If we’re trying to move our changes to a pre-existing branch, &lt;code&gt;git stash&lt;/code&gt; is a pretty useful command for shelving our changes temporarily&lt;/li&gt;
&lt;li&gt;If we ever do commit our changes to the wrong branch, we could always run a reset of any branch to rollback commits (and then continue to move our staged or un-stanged changes to the proper branch)&lt;/li&gt;
&lt;li&gt;If we ever pull down the wrong branch, we could run a hard reset&lt;/li&gt;
&lt;/ul&gt;

&lt;h4&gt;
  
  
  For Funsies
&lt;/h4&gt;

&lt;p&gt;Here are some extra useful commands:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;git stash list&lt;/code&gt; to view all of the stashes in our shelf&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;git stash pop &amp;lt;stashID&amp;gt;&lt;/code&gt; to pop a specific stash&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;git stash drop &amp;lt;stashID&amp;gt;&lt;/code&gt; to delete a stash from our shelf &lt;em&gt;use with caution&lt;/em&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;git reset -- &amp;lt;filepath&amp;gt;&lt;/code&gt; to un-stage a specific file from our index&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;git checkout &amp;lt;filepath&amp;gt;&lt;/code&gt; to undo/delete all changes of a specific file &lt;em&gt;use with caution&lt;/em&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;h6&gt;
  
  
  Resources:
&lt;/h6&gt;

&lt;ul&gt;
&lt;li&gt;git stash documentation: &lt;a href="https://git-scm.com/docs/git-stash"&gt;https://git-scm.com/docs/git-stash&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;git reset documentation: &lt;a href="https://git-scm.com/docs/git-reset"&gt;https://git-scm.com/docs/git-reset&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;git checkout documentation: &lt;a href="https://git-scm.com/docs/git-checkout"&gt;https://git-scm.com/docs/git-checkout&lt;/a&gt;
&lt;/li&gt;
&lt;/ul&gt;

</description>
      <category>git</category>
      <category>beginners</category>
    </item>
    <item>
      <title>React Context vs. Containment</title>
      <dc:creator>adelinealmanzar</dc:creator>
      <pubDate>Mon, 14 Mar 2022 18:56:46 +0000</pubDate>
      <link>https://dev.to/adelinealmanzar/react-context-vs-containment-319g</link>
      <guid>https://dev.to/adelinealmanzar/react-context-vs-containment-319g</guid>
      <description>&lt;p&gt;&lt;strong&gt;Context&lt;/strong&gt; allows us to pass data through the component tree without relying on props every time (often referred to as ‘broadcasting’ data). Implementing context is useful for when we need many components &lt;em&gt;at different nesting levels&lt;/em&gt; to have access to the same data (ex: UI theme, locale preference, current user) or in other words, when we need data to be considered ‘global’.&lt;/p&gt;

&lt;h3&gt;
  
  
  Implementing Context
&lt;/h3&gt;

&lt;p&gt;The following code breakdown is inspired from the UI theme use-case example provided by the &lt;a href="https://reactjs.org/docs/hooks-reference.html#usecontext"&gt;React documentation&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;To use and update context, first we would need to define our theme object from which we will be pulling the context values from.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;const themes = {
  light: {
    foreground: "#000000",
    background: "#eeeeee"
  },
  dark: {
    foreground: "#ffffff",
    background: "#222222"
  }
};
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Then we need to use &lt;code&gt;React.createContext&lt;/code&gt; to create a context for theme with a default value. In the code example below, we’re using the &lt;code&gt;themes.dark&lt;/code&gt; object as our default value.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;const ThemeContext = React.createContext(themes.dark)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;We then need to use &lt;code&gt;.Provider&lt;/code&gt; to provide an updated value for the specific context.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;function App() {
    return (
        //provide the theme context's value to change/update the previous theme context's value
        &amp;lt;ThemeContext.Provider value={themes.light}&amp;gt;
            &amp;lt;Navigation /&amp;gt;
        &amp;lt;/ThemeContext.Provider&amp;gt;
    )
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;To access our theme context value, we can use the &lt;code&gt;useContext(SpecifiedContext)&lt;/code&gt; hook. &lt;code&gt;useContext(ThemeContext)&lt;/code&gt; accepts our &lt;code&gt;ThemeContext&lt;/code&gt; context variable in the format of an object (the returned object value from &lt;code&gt;React.createContext&lt;/code&gt;) and it returns the current context value for the specific context. We can save this returned context value to a variable in order to use it in our code.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;function ThemedButton() {
    // save theme context value to theme variable
    const theme = useContext(ThemeContext)
    return (
        // use theme variable to manipulate button styling
        &amp;lt;button style={{ background: theme.background, color: theme.foreground }} &amp;gt;
            My styling comes from theme context!!!
        &amp;lt;/button&amp;gt;
    )

function Navigation() {
    // return our ThemedButton component to display our ThemeButton
    return &amp;lt;ThemedButton /&amp;gt;
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The current context value is determined by the &lt;em&gt;value&lt;/em&gt; prop of the nearest &lt;code&gt;SpecifiedContext.Provider&lt;/code&gt; above the calling component in the tree. When the nearest &lt;code&gt;SpecifiedContext.Provider&lt;/code&gt; above the component updates, the useContext hook will trigger a re-render with the updated latest context &lt;em&gt;value.&lt;/em&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  Implementing Containment
&lt;/h3&gt;

&lt;p&gt;Something to consider is that context makes component reuse harder. So, if we need to simply avoid the prop code redundancy of passing props through unnecessary intermediate levels, we should consider using the &lt;code&gt;children&lt;/code&gt; prop within component composition. Component composition is React’s original development model of using either explicitly defined props or using implicit children props to pass down JSX components or elements via &lt;strong&gt;containment&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;&lt;code&gt;children&lt;/code&gt; is a special prop that passes implicit children elements directly into a component’s output via nesting within the parent component.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;function ChildComponent(props) {
    return (
        &amp;lt;div&amp;gt;
            {props.children}
        &amp;lt;/div&amp;gt;
    )
}

function ParentComponent() {
    return (
        &amp;lt;ChildComponent&amp;gt;
            &amp;lt;h1&amp;gt;I am the first child prop!&amp;lt;/h1&amp;gt;
            &amp;lt;h2&amp;gt;I am the second child prop!&amp;lt;/h2&amp;gt;
        &amp;lt;/ChildComponent&amp;gt;
    )
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;We can make our own custom convention if we’re needing to use a more specific children-prop-breakdown.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;function ChildComponent(props) {
    return (
        &amp;lt;div&amp;gt;
            &amp;lt;div&amp;gt;{props.left}&amp;lt;/div&amp;gt;
            &amp;lt;div&amp;gt;{props.right}&amp;lt;/div&amp;gt;
        &amp;lt;/div&amp;gt;
    )
}

function ParentComponent() {
    return (
        &amp;lt;ChildComponent&amp;gt;
            left={&amp;lt;LeftChildComponent /&amp;gt;}
            right={&amp;lt;RightChildComponent /&amp;gt;}
        &amp;lt;/ChildComponent&amp;gt;
    )
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Containment is useful because we can pass down entire components or JSX elements down as props instead of passing down props through intermediate components.&lt;/p&gt;

&lt;p&gt;To read more on composition, feel free to refer to the &lt;a href="https://reactjs.org/docs/composition-vs-inheritance.html"&gt;React documentation on the topic&lt;/a&gt;.&lt;/p&gt;

&lt;h3&gt;
  
  
  TLDR:
&lt;/h3&gt;

&lt;p&gt;Containment can be used for most use cases when we simply need to decouple a child from its immediate parent (so that we don’t have so much redundancy in passing down props within intermediate relationships). Usually, this means that children and parent components have a singular nesting pattern.&lt;/p&gt;

&lt;p&gt;Context, on the other hand, is useful for ‘broadcasting’ our data - accessing data by many components &lt;em&gt;at different nesting levels.&lt;/em&gt;&lt;/p&gt;

&lt;h4&gt;
  
  
  Resources
&lt;/h4&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href="https://reactjs.org/docs/context.html"&gt;Context documentation&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://reactjs.org/docs/hooks-reference.html#usecontext"&gt;useContext hook documentation&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://reactjs.org/docs/composition-vs-inheritance.html"&gt;Composition documentation&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

</description>
      <category>beginners</category>
      <category>react</category>
    </item>
    <item>
      <title>A Git Pair Programming Workflow WalkThrough</title>
      <dc:creator>adelinealmanzar</dc:creator>
      <pubDate>Tue, 01 Mar 2022 01:51:32 +0000</pubDate>
      <link>https://dev.to/adelinealmanzar/a-git-pair-group-workflow-walkthrough-3a9f</link>
      <guid>https://dev.to/adelinealmanzar/a-git-pair-group-workflow-walkthrough-3a9f</guid>
      <description>&lt;p&gt;Git and Github exists to help us keep track of who is making a change in the remote versus local spaces especially when we're working collaboratively.&lt;/p&gt;

&lt;p&gt;Collaborative Git workflows are usually determined based on the team that we're working in. Since there are all sorts of team types that exists in the world, then there are also different workflows that exist. We'll be covering a workflow walkthrough for working in the same workstation (also known as pair programming).&lt;/p&gt;

&lt;p&gt;The following workflows are written with the assumption that we're working in a relatively small team (2-30 people).&lt;/p&gt;

&lt;h3&gt;
  
  
  Data Movement
&lt;/h3&gt;

&lt;p&gt;To review, our data moves from local locations to remote locations and vise versa.&lt;br&gt;
&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--UO0PN1q9--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/32lofjnx33f3n56ek44l.jpeg" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--UO0PN1q9--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/32lofjnx33f3n56ek44l.jpeg" alt="Image description" width="880" height="625"&gt;&lt;/a&gt;&lt;/p&gt;
&lt;h3&gt;
  
  
  One Workstation Workflow: for Pair Programming Team Members
&lt;/h3&gt;

&lt;p&gt;Person A Driving:&lt;br&gt;
Step 1. the first step to working with Git and Github is to clone the remote's repository with &lt;code&gt;git clone&lt;/code&gt;. Once Person A runs &lt;code&gt;git clone&lt;/code&gt; they're able to &lt;code&gt;cd&lt;/code&gt; into their local copy of the remote repository and start working locally.&lt;/p&gt;

&lt;p&gt;Then they can move on to steps 2-11. To view the more detailed walkthrough of these steps, feel free to read the previous blog post in this series on &lt;a href="https://dev.to/adelinealmanzar/a-git-individual-workflow-walkthrough-po7"&gt;Git Individual Workflow&lt;/a&gt;.&lt;br&gt;
Step 2. &lt;code&gt;git branch&lt;/code&gt;: view current branch &amp;amp; view all branches in our local repository&lt;br&gt;
Step 3. &lt;code&gt;git pull origin master&lt;/code&gt;: pull remote master branch data to our local master branch&lt;br&gt;
Step 4. &lt;code&gt;git checkout -b personA-branch&lt;/code&gt;: create a new local branch and move to that branch&lt;br&gt;
Step 5. &lt;code&gt;git branch&lt;/code&gt;: sanity check that we're in proper new branch&lt;br&gt;
Step 6. Make code changes&lt;br&gt;
Step 7. &lt;code&gt;git status&lt;/code&gt;: shows what files have had changes made &amp;amp; shows whether our files have been staged or not (green for yes, red for no)&lt;br&gt;
Step 8. &lt;code&gt;git add filePath/wanting/toStage.txt&lt;/code&gt;: add files, via their file paths, to the staging/index area&lt;br&gt;
Step 9. &lt;code&gt;git status&lt;/code&gt;: sanity check that only preferred files are staged/added to index&lt;br&gt;
Step 10. &lt;code&gt;git commit -m "any commit message"&lt;/code&gt;: snapshot currently staged changes via a singular commit &amp;amp; write concise message&lt;br&gt;
Step 11. &lt;code&gt;git log&lt;/code&gt;: view our commit history to sanity check that our most recent commit is at the top of the history list&lt;/p&gt;

&lt;p&gt;Step 12. Person A can keep making local code changes and looping through steps 6-11 before moving on to step 13.&lt;/p&gt;

&lt;p&gt;Step 13. Once Person A's local repository is at a ready-enough state for their team's review and/or collaboration, they can push their changes to the remote repository with &lt;code&gt;git push origin personA-branch&lt;/code&gt;.&lt;br&gt;
&lt;code&gt;git push&lt;/code&gt; will send all of Person A's local repository's commits and branches to the remote repository (in Github).&lt;/p&gt;

&lt;p&gt;Step 14. When Person A signs into Github and visits the remote repository, they should be able to create a new pull request(PR). Pull requests are akin to a form requesting to officially merge Person A's changes to the remote branch they originally branched-off of. PRs enable team members to share the purpose of their code changes in layman's terms. PRs also enable team members access to review changes and view diffs from making changes collaboratively.&lt;/p&gt;

&lt;p&gt;At this point, Person A can take a backseat for the moment while Person B drives.&lt;/p&gt;

&lt;p&gt;Person B Driving:&lt;br&gt;
Step 15. Person B will need to &lt;code&gt;git clone&lt;/code&gt; the remote repository to have a local copy of the repository on their machine, same as Person A had.&lt;/p&gt;

&lt;p&gt;The fun part is that now that Person A's work is available remotely (because Person A &lt;code&gt;git push&lt;/code&gt;-ed), Person B can fetch and checkout a local copy of the remote branch that Person A just pushed.&lt;/p&gt;

&lt;p&gt;Step 16. &lt;code&gt;git fetch --all&lt;/code&gt; fetches all remote branches and makes those branches available locally to Person B.&lt;br&gt;
Fetch &lt;em&gt;will not&lt;/em&gt; move any code changes; fetch will only move &lt;em&gt;meta data&lt;/em&gt; (such as branches) from the remote space to Person B's local machine. So, Person B can fetch in any branch and as often as they like.&lt;/p&gt;

&lt;p&gt;Step 17. After fetching, Person B is able to checkout Person A's branch.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;user@ repo-name % git checkout personA-branch     
Branch 'personA-branch' set up to track remote branch 'personA-branch' from 'origin'.
Switched to a new branch 'personA-branch'
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Running &lt;code&gt;git checkout&lt;/code&gt; will 1. create a new local branch, called &lt;code&gt;personA-branch&lt;/code&gt; in Person B's workspace, 2. set up this newly created local branch to track its remote counterpart with the same name, and 3. place Person B in their newly created local &lt;code&gt;personA-branch&lt;/code&gt; copy branch.&lt;/p&gt;

&lt;p&gt;Step 18. Running &lt;code&gt;git branch&lt;/code&gt; again to sanity check that Person B is in the proper branch should yield something like this:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;userB@ repo-name % git branch
master
*personA-branch
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Step 19. Now, when Person B runs &lt;code&gt;git pull&lt;/code&gt;, they are pulling the updated commit history from Person A's remote branch (called &lt;code&gt;personA-branch&lt;/code&gt;) to Person B's local copy of Person A's branch (also called &lt;code&gt;personA-branch&lt;/code&gt;). If the remote repository has no changes, then &lt;code&gt;git pull&lt;/code&gt; will show an 'Already up to date' message.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;user@ repo-name % git pull origin personA-branch
From github.com:PersonA/repo-name
 * branch         personA-branch     -&amp;gt; FETCH_HEAD
Already up to date.
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Reminder: everyone should &lt;code&gt;git pull&lt;/code&gt; &lt;em&gt;only&lt;/em&gt; the remote branch name that matches the local branch they are currently in.&lt;/p&gt;

&lt;p&gt;Step 20. Person B's local copy of PersonA's branch will end up tracking the version history of Person B's local changes via commits.&lt;br&gt;
So, Person B can go ahead and complete steps 6 - 11 while making code changes and adding those to their commit history.&lt;br&gt;
&lt;code&gt;git log&lt;/code&gt; within the 11th step will show Person B's local commit history that Person B made to their local copy of Person A's branch.&lt;/p&gt;

&lt;p&gt;Step 21. In order to update Person A's remote branch, Person B would run &lt;code&gt;git push origin personA-branch&lt;/code&gt;.&lt;br&gt;
On Github, Person A and Person B should both see the remote branch was updated with Person B's commit history.&lt;/p&gt;

&lt;p&gt;To switch drivers, Person A and Person B can each take turns with steps 17-21 until the PR is ready to be reviewed and merged to the branch PersonA's branch had originally branched off from.&lt;/p&gt;

&lt;h2&gt;
  
  
  TLDR: One Workstation Workflow (for Pair Programming)
&lt;/h2&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;code&gt;git clone repo-link &amp;amp;&amp;amp; cd PersonA-repo&lt;/code&gt;: make a clone/local copy of PersonA’s remote repository and move into it&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;git branch&lt;/code&gt;: view current branch &amp;amp; view all branches in our local repository&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;git pull origin master&lt;/code&gt;: pull remote master branch data to our local master branch&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;git checkout -b personA-branch&lt;/code&gt;: create a new local branch and move to that branch&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;git branch&lt;/code&gt;: sanity check that we're in proper new branch&lt;/li&gt;
&lt;li&gt;Make code changes&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;git status&lt;/code&gt;: shows what files have had changes made &amp;amp; shows whether our files have been staged or not (green for yes, red for no)&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;git add filePath/wanting/toStage.txt&lt;/code&gt;: add files, via their file paths, to the staging/index area&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;git status&lt;/code&gt;: sanity check that only preferred files are staged/added to index&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;git commit -m "any commit message"&lt;/code&gt;: snapshot currently staged changes via a singular commit &amp;amp; write concise message&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;git log&lt;/code&gt;: to view commit history to sanity check that most recent commit is at the top of the history list&lt;/li&gt;
&lt;li&gt;Driver can keep making local code changes and looping through steps 6-11 before moving on to step 13&lt;/li&gt;
&lt;li&gt; &lt;code&gt;git push origin personA-branch&lt;/code&gt; push driver’s commit history to remote repository&lt;/li&gt;
&lt;li&gt;Driver creates pull request(PR) in Github &amp;amp; drivers switch (so from this point forward, actions should be of new driver)&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;git clone repo-link &amp;amp;&amp;amp; cd repo-name&lt;/code&gt; clone the remote repository to the new driver’s local machine&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;git fetch --all&lt;/code&gt; fetches all remote branches and makes those branches available locally to the new driver&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;git checkout personA-branch&lt;/code&gt; in the new driver’s workspace: creates a new branch that matches the remote branch name (personA-branch), tracks the remote counterpart, and places the new driver in their local &lt;code&gt;personA-branch&lt;/code&gt; branch&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;git branch&lt;/code&gt; to sanity check that new driver is in the proper &lt;code&gt;personA-branch&lt;/code&gt; branch.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;git pull origin personA-branch&lt;/code&gt; pulls the updated commit history from Person A's remote branch (called &lt;code&gt;personA-branch&lt;/code&gt;) to Person B's local copy of Person A's branch (also called &lt;code&gt;personA-branch&lt;/code&gt;)&lt;/li&gt;
&lt;li&gt;New driver can keep making code changes and adding those to the commit history by repeating steps 6 - 11&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;git push origin personA-branch&lt;/code&gt; update remote &lt;code&gt;personA-branch&lt;/code&gt; with new driver’s local commit history&lt;/li&gt;
&lt;li&gt;Switch drivers and new driver will repeat steps 17-21 until PR is ready for to be reviewed and merged&lt;/li&gt;
&lt;/ol&gt;

&lt;h4&gt;
  
  
  Resources
&lt;/h4&gt;

&lt;ol&gt;
&lt;li&gt;&lt;a href="https://education.github.com/git-cheat-sheet-education.pdf"&gt;A git commands cheat sheet&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://github.com/git-guides/"&gt;Git Guides&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://git-scm.com/docs/git-fetch"&gt;Git fetch documentation&lt;/a&gt;&lt;/li&gt;
&lt;/ol&gt;

</description>
      <category>git</category>
      <category>github</category>
      <category>beginners</category>
    </item>
    <item>
      <title>A Git Individual Workflow WalkThrough</title>
      <dc:creator>adelinealmanzar</dc:creator>
      <pubDate>Mon, 14 Feb 2022 21:06:09 +0000</pubDate>
      <link>https://dev.to/adelinealmanzar/a-git-individual-workflow-walkthrough-po7</link>
      <guid>https://dev.to/adelinealmanzar/a-git-individual-workflow-walkthrough-po7</guid>
      <description>&lt;p&gt;Git and its workflows can be initially hard concepts to wrap our heads around.&lt;/p&gt;

&lt;p&gt;Git is a version control system that lets us keep track of and manage code history. Github is a cloud-based hosting service that helps to manage Git repositories (repos).&lt;/p&gt;

&lt;p&gt;Some cool things about Git are that it's based off of a branching model and it's mostly local. Github, on the other hand, is exclusively remote/cloud-based, which allows different people to view, clone, and collaborate with our code.&lt;/p&gt;

&lt;h3&gt;
  
  
  Flow of Data with Git and Github
&lt;/h3&gt;

&lt;p&gt;Our workflows are going to follow the interaction between our machine (local changes via Git) and the hosting service (remote changes stored via Github history).&lt;br&gt;
For the purposes of simplicity, from this point onwards we're going to use 'local' and 'remote' keywords to refer to our local machines and remote repositories/branches.&lt;/p&gt;

&lt;p&gt;Data can be considered within two types:&lt;br&gt;
(a) dynamic instance data, such as code files and their contents&lt;br&gt;
(b) static metadata, such as our branches and commits with user information (or 'git blame' data)&lt;/p&gt;

&lt;p&gt;At a high level we could say that our data moves from local locations to remote locations and vise versa&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fwfxjkm004tzkx38wi1ao.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fwfxjkm004tzkx38wi1ao.jpg" alt="Movement of Data Flow Chart"&gt;&lt;/a&gt;&lt;/p&gt;
&lt;h3&gt;
  
  
  Walkthrough of personal workflow
&lt;/h3&gt;

&lt;p&gt;Now what happens when we make changes locally and how do we do that?&lt;br&gt;
After we copy the remote's repository with &lt;code&gt;git clone&lt;/code&gt;, we are able to work within Git's branching system locally.&lt;/p&gt;

&lt;p&gt;When we &lt;code&gt;git pull&lt;/code&gt; we're pulling a copy of a specific branch from the remote repository to our local workspace. If there haven't been any changes to the remote repository, then when we &lt;code&gt;git pull&lt;/code&gt; we will get an 'Already up to date' message.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;user@ repo-name % git pull origin main
From github.com:adelinealmanzar/repo-name
 * branch            main       -&amp;gt; FETCH_HEAD
Already up to date.
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;We should &lt;code&gt;git pull&lt;/code&gt; &lt;em&gt;only&lt;/em&gt; the remote branch name that matches the local branch we are currently in.&lt;br&gt;
We can check which branch we're currently located in with &lt;code&gt;git branch&lt;/code&gt;.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;user@ repo-name % git branch
* master
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Imagine your master or main branch is the trunk of a tree. Whatever branches we create out of that trunk will be almost like draft branches because they will only exist in our local workspace and then eventually into our local repository, where those draft branches will be reviewed and edited.&lt;/p&gt;

&lt;p&gt;When we &lt;code&gt;git checkout -b any-new-branch-name&lt;/code&gt; we're creating new local branches off of the master/main root branch and we're moving to that branch.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;user@ repo-name % git checkout -b any-new-branch     
Switched to a new branch 'any-new-branch'
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;We can do &lt;code&gt;git branch&lt;/code&gt; again to sanity-check that we're in fact in our new branch&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;user@ repo-name % git branch
* any-new-branch
  master
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Our new branch will end up tracking the version history of our changes via commits. But before we commit to our official remote repository history, we must stage those changes in our index. We can check which files are staged via &lt;code&gt;git status&lt;/code&gt;. &lt;code&gt;git status&lt;/code&gt; displays files that have (or have not) been changed in the working directory and the staged directory.&lt;/p&gt;

&lt;p&gt;If we've made no changes to any files, running git status will tell us that we have a clean working tree&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;user@ repo-name % git status
On branch any-new-branch
nothing to commit, working tree clean
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;So lets add some code changes and then see what git status looks like.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;user@ repo-name % git status
On branch any-new-branch
Changes not staged for commit:
  (use "git add &amp;lt;file&amp;gt;..." to update what will be committed)
  (use "git restore &amp;lt;file&amp;gt;..." to discard changes in working directory)
    modified:   src/components/Header.js
        modified:   src/components/MainContainer.j

no changes added to commit (use "git add" and/or "git commit -a")
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Any modification that we make to a file will show up under our workspace area(located after 'changes not staged for commit' in red). In order to add those changes to our index, we must run &lt;code&gt;git add &amp;lt;file-name&amp;gt;&lt;/code&gt;.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;user@ repo-name % git status
On branch any-new-branch
Changes to be committed:
  (use "git restore --staged &amp;lt;file&amp;gt;..." to unstage)
    modified:   src/components/Header.js

Changes not staged for commit:
  (use "git add &amp;lt;file&amp;gt;..." to update what will be committed)
  (use "git restore &amp;lt;file&amp;gt;..." to discard changes in working directory)
    modified:   src/components/MainContainer.js

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;code&gt;git add&lt;/code&gt; adds new or modified files (from our workspace) to our staging area (located after 'changes to be committed' in green). &lt;code&gt;git add&lt;/code&gt; gives us the benefit of choice in deciding which files and changes we would like to commit. Based on Github's Git Guides, commits should be logical, atomic units of change. Tech teams usually organize their commits based on whichever rule of logic their organization/company practices. An example rule may be that each commit must contain all changes made to an individual file or that each commit must bucket one specific value within a feature. Why implement logical rules for commits? A clean commit history is usually easy to read, helpful for debugging, and helpful for understanding which changes we might end up needing to revert.&lt;/p&gt;

&lt;p&gt;To add our changes to an individual commit and create an easy-to-understand commit message, we run &lt;code&gt;git commit -m "any commit message"&lt;/code&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;user@ repo-name % git commit -m "perf: cleanup/removed debugging comments"
[any-new-branch 71a72da] perf: cleanup/removed debugging comments
 1 file changed, 1 insertion(+), 1 deletion(-)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Commit messages should describe what kind of change we've made to our code. In the above example, our commit message indicates that our changes included file cleanup of removing some sudo-code that was no longer needed. The &lt;code&gt;perf&lt;/code&gt; header indicates that the change we made was a removal. This &lt;code&gt;perf&lt;/code&gt; header is one of several semantic-release headers and footers that we can add to our commit message to indicate the type of change we've made to our code (addition, removal, patch/fix, or breaking change). To read more on semantic headers, you can &lt;a href="https://semantic-release.gitbook.io/semantic-release/" rel="noopener noreferrer"&gt;read more here&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;After we've committed our changes, we can &lt;code&gt;git log&lt;/code&gt; to view our commit history and sanity check that our commit is in the right place in history. The log commits are in order of most to least recent, so our most recent commit should be at the top, which we can see in the code below.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;commit 71a72da43ca6cdd9774c8abf00a96fb3f6c6d0b9 (HEAD -&amp;gt; any-new-branch)
Author: Adeline Almanzar &amp;lt;almanzar.adeline@gmail.com&amp;gt;
Date:   Sun Feb 13 11:31:50 2022 -0800

    perf: cleanup/removed debugging comments

commit 84c056344662503041c6fd3d5365f805dfca08e8 (master)
Author: Adeline Almanzar &amp;lt;almanzar.adeline@gmail.com&amp;gt;
Date:   Mon Feb 7 20:38:54 2022 -0800

    third deliverable
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Each commit in the log will have a commit ID, information on the author of the commit, the date &amp;amp; time of the commit, and the commit message.&lt;/p&gt;

&lt;p&gt;Now that we've committed our changes and done our sanity-checking, at this point we can keep going through the changes workflow to continue committing our changes to our local repository.&lt;/p&gt;

&lt;p&gt;Once our local repository is at a ready-enough state for our team's review and/or collaboration, we can push our changes to the remote repository with &lt;code&gt;git push origin &amp;lt;branch-name&amp;gt;&lt;/code&gt;.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;user@ repo-name % git push origin any-new-branch
Enumerating objects: 29, done.
Counting objects: 100% (29/29), done.
Delta compression using up to 8 threads
Compressing objects: 100% (28/28), done.
Writing objects: 100% (28/28), 286.05 KiB | 3.11 MiB/s, done.
Total 28 (delta 0), reused 0 (delta 0), pack-reused 0
To github.com:adelinealmanzar/repo-name.git
   84c0563..71a72da  any-new-branch -&amp;gt; any-new-branch
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;code&gt;git push&lt;/code&gt; will send all of our local repository's commits and branches to the remote repository (in Github). When we sign into Github and visit the remote repository, we should be able to create a new pull request(PR). We can think of our pull request as a form that we submit to our team with the request to officially merge our changes to the remote branch we originally branched-off of. PRs enable us to share the purpose of our code changes in layman's terms. They also enable our team members access to review our changes and make changes themselves (stay tuned for my next blog post on collaborative workflows).&lt;/p&gt;

&lt;h2&gt;
  
  
  TLDR: Personal Workflow Summary
&lt;/h2&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;code&gt;git clone repo-link &amp;amp;&amp;amp; cd repo-name&lt;/code&gt;: make a clone/local copy of the remote repository and move into it&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;git branch&lt;/code&gt;: view current branch &amp;amp; view all branches in our local repository&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;git pull origin master&lt;/code&gt;: pull remote master branch data to our local master branch&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;git checkout -b new-branch-name&lt;/code&gt;: create a new local branch and move to that branch&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;git branch&lt;/code&gt;: sanity check that we're in proper new branch&lt;/li&gt;
&lt;li&gt;Make code changes&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;git status&lt;/code&gt;: shows what files have had changes made &amp;amp; shows whether our files have been staged or not (green for yes, red for no)&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;git add filePath/wanting/toStage.txt&lt;/code&gt;: add files, via their file paths, to the staging/index area&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;git status&lt;/code&gt;: sanity check that only preferred files are staged/added to index&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;git commit -m "any commit message"&lt;/code&gt;: snapshot currently staged changes via a singular commit &amp;amp; write concise message&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;git log&lt;/code&gt;: view our commit history to sanity check that our most recent commit is at the top of the history list&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;git push origin new-branch&lt;/code&gt;: push our local new-branch and its data to the remote space (Github)&lt;/li&gt;
&lt;li&gt;Create pull request on Github&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;git branch&lt;/code&gt;: sanity check that current branch is still new-branch&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;git pull origin new-branch&lt;/code&gt;: pull (to our local new-branch) any changes that might have been added from the remote new-branch&lt;/li&gt;
&lt;li&gt;(a) If making changes to the same branch, repeat steps 6-12
(b) If making changes to a different branch, repeat steps 5-12&lt;/li&gt;
&lt;/ol&gt;

&lt;h4&gt;
  
  
  Resources:
&lt;/h4&gt;

&lt;ol&gt;
&lt;li&gt;&lt;a href="https://krishnaiitd.github.io/gitcommands/git-workflow/" rel="noopener noreferrer"&gt;Another git workflow &amp;amp; commands explanation&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://education.github.com/git-cheat-sheet-education.pdf" rel="noopener noreferrer"&gt;A git commands cheat sheet&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://github.com/git-guides/" rel="noopener noreferrer"&gt;Git Guides&lt;/a&gt;&lt;/li&gt;
&lt;/ol&gt;

</description>
      <category>git</category>
      <category>github</category>
      <category>tutorial</category>
      <category>beginners</category>
    </item>
  </channel>
</rss>
