{"id":1152,"date":"2019-01-08T05:10:51","date_gmt":"2019-01-08T05:10:51","guid":{"rendered":"http:\/\/www.afternerd.com\/blog\/?p=1152"},"modified":"2019-08-19T18:13:13","modified_gmt":"2019-08-19T18:13:13","slug":"learn-git","status":"publish","type":"post","link":"https:\/\/www.afternerd.com\/blog\/learn-git\/","title":{"rendered":"Learn Git (A Tutorial for Beginners)"},"content":{"rendered":"<p>Being an excellent programmer is not only about learning programming. Programmers need tools to assist them with their work. And one of the most important tools that programmers use every single day is git.<\/p>\n<h3>What is git?<\/h3>\n<p>git is a <a href=\"https:\/\/en.wikipedia.org\/wiki\/Version_control\" target=\"_blank\" rel=\"noopener noreferrer\">version control system.<\/a><\/p>\n<p>A version control system, in the simplest terms, allows you to maintain different versions (snapshots) of your code while your code is growing.<\/p>\n<p>And this gives you the following benefits.<\/p>\n<p><strong>1- disaster recovery<\/strong><\/p>\n<p>Since a version control system allows you to have different versions of your source code. If your newest version is not working for whatever reason (may be it&#8217;s that new hire), you can easily roll back to a version of the code that you know is working.<\/p>\n<p><strong>2- collaboration<\/strong><\/p>\n<p>Version control systems facilitate collaborative development.<\/p>\n<p>Development as a team would have been a nightmare without systems like git (and others).<\/p>\n<p><strong>With that said, git is the most popular version control system there is nowadays. And this is likely to last for some serious time. You can quote me on that.<\/strong><\/p>\n<p>So now that you are sold on the importance of git, how do you learn git?<\/p>\n<p>In the rest of this article, I will cover the 5 steps that you need to progress through while learning git.<\/p>\n<p>I will do this by walking you through a very basic tutorial.<\/p>\n<p>For each step, I&#8217;m going to cover the basics but it&#8217;s up to you to go ahead and make sure you understand each topic in depth by fiddling with git yourself and reading more resources.<\/p>\n<p>Follow these steps, in the presented order, and make sure you study each step thoroughly before you move on to the next one.<\/p>\n<p>Here is what this article will cover.<\/p>\n<ul>\n<li><a href=\"#forget-github\">Forget about github, learn git locally<\/a>\n<ul>\n<li><a href=\"#create-repo\">Creating a git repository<\/a><\/li>\n<li><a href=\"#stage\">Staging your changes<\/a><\/li>\n<li><a href=\"#commit\">Committing your changes<\/a><\/li>\n<\/ul>\n<\/li>\n<li><a href=\"#branch-out\">Branch out<\/a><\/li>\n<li><a href=\"#merge-branches\">Learn how to merge branches<\/a><\/li>\n<li><a href=\"#resolve-conflicts\">Learn how to resolve merge conflicts<\/a><\/li>\n<li><a href=\"#git-remotes\">Get comfortable with git remotes<\/a><\/li>\n<\/ul>\n<h2 id=\"forget-github\">Step 1: Forget about Github, learn git locally<\/h2>\n<p>To avoid any confusion, and to make sure that your learning process starts out with the right mindset, I want you to completely forget that <a href=\"https:\/\/www.github.com\" target=\"_blank\" rel=\"noopener noreferrer\">Github<\/a> exist.<\/p>\n<p>The reason is that many beginners confuse git with Github.<\/p>\n<p>They are two completely separate things.<\/p>\n<p>By pretending that Github doesn&#8217;t exist, you will be able to gather the git concepts much faster.<\/p>\n<p>In this step, all you need is your laptop.<\/p>\n<p>You don&#8217;t even need an internet connection.<\/p>\n<p>Let&#8217;s get started.<\/p>\n<h3 id=\"create-repo\">First: Creating a git repository<\/h3>\n<p>Let&#8217;s say you want to start working on a new coding project. Let&#8217;s call it <strong>helloworld.<\/strong><\/p>\n<p>So you go ahead and create a directory called <strong>helloworld<\/strong> where you will store all your project source files.<\/p>\n<p>Now because you are a smart person, you know that you need to create a git repo in order to version control your source code.<\/p>\n<p>Doing so is stupid easy!<\/p>\n<p>Just head to the <strong>helloworld<\/strong> directory and run the <span class=\"symbol\">git init<\/span> command:<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-1154\" src=\"http:\/\/www.afternerd.com\/blog\/wp-content\/uploads\/2018\/12\/Screen-Shot-2018-12-28-at-9.10.39-PM.png\" alt=\"\" width=\"2150\" height=\"236\" srcset=\"https:\/\/www.afternerd.com\/blog\/wp-content\/uploads\/2018\/12\/Screen-Shot-2018-12-28-at-9.10.39-PM.png 2150w, https:\/\/www.afternerd.com\/blog\/wp-content\/uploads\/2018\/12\/Screen-Shot-2018-12-28-at-9.10.39-PM-300x33.png 300w, https:\/\/www.afternerd.com\/blog\/wp-content\/uploads\/2018\/12\/Screen-Shot-2018-12-28-at-9.10.39-PM-768x84.png 768w, https:\/\/www.afternerd.com\/blog\/wp-content\/uploads\/2018\/12\/Screen-Shot-2018-12-28-at-9.10.39-PM-1024x112.png 1024w, https:\/\/www.afternerd.com\/blog\/wp-content\/uploads\/2018\/12\/Screen-Shot-2018-12-28-at-9.10.39-PM-200x22.png 200w, https:\/\/www.afternerd.com\/blog\/wp-content\/uploads\/2018\/12\/Screen-Shot-2018-12-28-at-9.10.39-PM-400x44.png 400w, https:\/\/www.afternerd.com\/blog\/wp-content\/uploads\/2018\/12\/Screen-Shot-2018-12-28-at-9.10.39-PM-600x66.png 600w, https:\/\/www.afternerd.com\/blog\/wp-content\/uploads\/2018\/12\/Screen-Shot-2018-12-28-at-9.10.39-PM-800x88.png 800w, https:\/\/www.afternerd.com\/blog\/wp-content\/uploads\/2018\/12\/Screen-Shot-2018-12-28-at-9.10.39-PM-1200x132.png 1200w\" sizes=\"(max-width: 2150px) 100vw, 2150px\" \/><\/p>\n<p>And just like that, you have a git repo.<\/p>\n<p>It&#8217;s time to start actually writing code!<\/p>\n<p>For simplicity, let&#8217;s create a <strong>README.md<\/strong> file and a Python <em>hello world<\/em> program <strong>hello.py<\/strong><\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-1158\" src=\"http:\/\/www.afternerd.com\/blog\/wp-content\/uploads\/2018\/12\/Screen-Shot-2018-12-28-at-9.25.16-PM.png\" alt=\"\" width=\"2350\" height=\"776\" srcset=\"https:\/\/www.afternerd.com\/blog\/wp-content\/uploads\/2018\/12\/Screen-Shot-2018-12-28-at-9.25.16-PM.png 2350w, https:\/\/www.afternerd.com\/blog\/wp-content\/uploads\/2018\/12\/Screen-Shot-2018-12-28-at-9.25.16-PM-300x99.png 300w, https:\/\/www.afternerd.com\/blog\/wp-content\/uploads\/2018\/12\/Screen-Shot-2018-12-28-at-9.25.16-PM-768x254.png 768w, https:\/\/www.afternerd.com\/blog\/wp-content\/uploads\/2018\/12\/Screen-Shot-2018-12-28-at-9.25.16-PM-1024x338.png 1024w, https:\/\/www.afternerd.com\/blog\/wp-content\/uploads\/2018\/12\/Screen-Shot-2018-12-28-at-9.25.16-PM-200x66.png 200w, https:\/\/www.afternerd.com\/blog\/wp-content\/uploads\/2018\/12\/Screen-Shot-2018-12-28-at-9.25.16-PM-400x132.png 400w, https:\/\/www.afternerd.com\/blog\/wp-content\/uploads\/2018\/12\/Screen-Shot-2018-12-28-at-9.25.16-PM-600x198.png 600w, https:\/\/www.afternerd.com\/blog\/wp-content\/uploads\/2018\/12\/Screen-Shot-2018-12-28-at-9.25.16-PM-800x264.png 800w, https:\/\/www.afternerd.com\/blog\/wp-content\/uploads\/2018\/12\/Screen-Shot-2018-12-28-at-9.25.16-PM-1200x396.png 1200w\" sizes=\"(max-width: 2350px) 100vw, 2350px\" \/><\/p>\n<h3 id=\"stage\">Second: Staging your changes<\/h3>\n<p>By creating these two file, you have populated your <strong>directory<\/strong>. However, your <strong>git repo<\/strong> is still empty!<\/p>\n<blockquote><p>The first rule of git is, your working directory is NOT your repo<\/p><\/blockquote>\n<p>The reason your git repo is empty is because you need to explicitly tell git to take a <strong>snapshot<\/strong> of your code.<\/p>\n<p>Each snapshot (or version) of your code is called a <strong>commit\u00a0<\/strong>and each commit is uniquely identified by a hash which is a function of the content of your source files, some metadata, and other things.<\/p>\n<p>To tell git to take a snapshot of your code, you do so by first staging the files that you created or modified and then committing them.<\/p>\n<p>Staging a file means that you are telling git to take the changes in that file into consideration the next time you take a snapshot of your code.<\/p>\n<p>For example, to stage\u00a0<strong>hello.py<\/strong>, you run the <span class=\"symbol\">git add<\/span> command.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-1159\" src=\"http:\/\/www.afternerd.com\/blog\/wp-content\/uploads\/2018\/12\/Screen-Shot-2018-12-28-at-9.48.33-PM.png\" alt=\"\" width=\"2248\" height=\"152\" srcset=\"https:\/\/www.afternerd.com\/blog\/wp-content\/uploads\/2018\/12\/Screen-Shot-2018-12-28-at-9.48.33-PM.png 2248w, https:\/\/www.afternerd.com\/blog\/wp-content\/uploads\/2018\/12\/Screen-Shot-2018-12-28-at-9.48.33-PM-300x20.png 300w, https:\/\/www.afternerd.com\/blog\/wp-content\/uploads\/2018\/12\/Screen-Shot-2018-12-28-at-9.48.33-PM-768x52.png 768w, https:\/\/www.afternerd.com\/blog\/wp-content\/uploads\/2018\/12\/Screen-Shot-2018-12-28-at-9.48.33-PM-1024x69.png 1024w, https:\/\/www.afternerd.com\/blog\/wp-content\/uploads\/2018\/12\/Screen-Shot-2018-12-28-at-9.48.33-PM-200x14.png 200w, https:\/\/www.afternerd.com\/blog\/wp-content\/uploads\/2018\/12\/Screen-Shot-2018-12-28-at-9.48.33-PM-400x27.png 400w, https:\/\/www.afternerd.com\/blog\/wp-content\/uploads\/2018\/12\/Screen-Shot-2018-12-28-at-9.48.33-PM-600x41.png 600w, https:\/\/www.afternerd.com\/blog\/wp-content\/uploads\/2018\/12\/Screen-Shot-2018-12-28-at-9.48.33-PM-800x54.png 800w, https:\/\/www.afternerd.com\/blog\/wp-content\/uploads\/2018\/12\/Screen-Shot-2018-12-28-at-9.48.33-PM-1200x81.png 1200w\" sizes=\"(max-width: 2248px) 100vw, 2248px\" \/><\/p>\n<p>Cool, now git knows that the next time you take a snapshot of your code<strong> hello.py<\/strong> will be included.<\/p>\n<h3 id=\"commit\">Third: Committing your changes<\/h3>\n<p>Committing your changes is the actual act of taking a snapshot of your code.<\/p>\n<p>But again remember that this snapshot will only contain the changes in the files that you have staged in the previous step.<\/p>\n<p>These changes could be adding, removing, or modifying the contents of a file.<\/p>\n<p>In our case, there is one change that we staged and that is creating a new file <strong>hello.py<\/strong><\/p>\n<p>Even though we also created a <strong>README<\/strong> file, git will not see the new file until it is staged as well.<\/p>\n<p>To create a commit, you use the <span class=\"symbol\">git commit<\/span> command and you also provide a nice, descriptive message about this commit.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-1161\" src=\"http:\/\/www.afternerd.com\/blog\/wp-content\/uploads\/2018\/12\/Screen-Shot-2018-12-28-at-9.58.45-PM-1.png\" alt=\"\" width=\"2836\" height=\"430\" srcset=\"https:\/\/www.afternerd.com\/blog\/wp-content\/uploads\/2018\/12\/Screen-Shot-2018-12-28-at-9.58.45-PM-1.png 2836w, https:\/\/www.afternerd.com\/blog\/wp-content\/uploads\/2018\/12\/Screen-Shot-2018-12-28-at-9.58.45-PM-1-300x45.png 300w, https:\/\/www.afternerd.com\/blog\/wp-content\/uploads\/2018\/12\/Screen-Shot-2018-12-28-at-9.58.45-PM-1-768x116.png 768w, https:\/\/www.afternerd.com\/blog\/wp-content\/uploads\/2018\/12\/Screen-Shot-2018-12-28-at-9.58.45-PM-1-1024x155.png 1024w, https:\/\/www.afternerd.com\/blog\/wp-content\/uploads\/2018\/12\/Screen-Shot-2018-12-28-at-9.58.45-PM-1-200x30.png 200w, https:\/\/www.afternerd.com\/blog\/wp-content\/uploads\/2018\/12\/Screen-Shot-2018-12-28-at-9.58.45-PM-1-400x61.png 400w, https:\/\/www.afternerd.com\/blog\/wp-content\/uploads\/2018\/12\/Screen-Shot-2018-12-28-at-9.58.45-PM-1-600x91.png 600w, https:\/\/www.afternerd.com\/blog\/wp-content\/uploads\/2018\/12\/Screen-Shot-2018-12-28-at-9.58.45-PM-1-800x121.png 800w, https:\/\/www.afternerd.com\/blog\/wp-content\/uploads\/2018\/12\/Screen-Shot-2018-12-28-at-9.58.45-PM-1-1200x182.png 1200w\" sizes=\"(max-width: 2836px) 100vw, 2836px\" \/><\/p>\n<p>Perfect.<\/p>\n<p>Let&#8217;s also stage and commit the <strong>README.md<\/strong>.\u00a0<img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-1162\" src=\"http:\/\/www.afternerd.com\/blog\/wp-content\/uploads\/2018\/12\/Screen-Shot-2018-12-28-at-10.16.11-PM.png\" alt=\"\" width=\"2608\" height=\"510\" srcset=\"https:\/\/www.afternerd.com\/blog\/wp-content\/uploads\/2018\/12\/Screen-Shot-2018-12-28-at-10.16.11-PM.png 2608w, https:\/\/www.afternerd.com\/blog\/wp-content\/uploads\/2018\/12\/Screen-Shot-2018-12-28-at-10.16.11-PM-300x59.png 300w, https:\/\/www.afternerd.com\/blog\/wp-content\/uploads\/2018\/12\/Screen-Shot-2018-12-28-at-10.16.11-PM-768x150.png 768w, https:\/\/www.afternerd.com\/blog\/wp-content\/uploads\/2018\/12\/Screen-Shot-2018-12-28-at-10.16.11-PM-1024x200.png 1024w, https:\/\/www.afternerd.com\/blog\/wp-content\/uploads\/2018\/12\/Screen-Shot-2018-12-28-at-10.16.11-PM-200x39.png 200w, https:\/\/www.afternerd.com\/blog\/wp-content\/uploads\/2018\/12\/Screen-Shot-2018-12-28-at-10.16.11-PM-400x78.png 400w, https:\/\/www.afternerd.com\/blog\/wp-content\/uploads\/2018\/12\/Screen-Shot-2018-12-28-at-10.16.11-PM-600x117.png 600w, https:\/\/www.afternerd.com\/blog\/wp-content\/uploads\/2018\/12\/Screen-Shot-2018-12-28-at-10.16.11-PM-800x156.png 800w, https:\/\/www.afternerd.com\/blog\/wp-content\/uploads\/2018\/12\/Screen-Shot-2018-12-28-at-10.16.11-PM-1200x235.png 1200w\" sizes=\"(max-width: 2608px) 100vw, 2608px\" \/><\/p>\n<div class=\"side-note\">Note that I could have staged both files before I commit, but I chose not to so I can illustrate to you that only changes in the staging area are considered when you commit.<\/div>\n<p>By now, you should have two commits in your repo.<\/p>\n<p>Each commit you make is stored in the git repo with a pointer to its parent commit, much like how a <a href=\"https:\/\/www.geeksforgeeks.org\/linked-list-set-1-introduction\/\" target=\"_blank\" rel=\"noopener noreferrer\">linked list<\/a> would look like.<\/p>\n<p>So if you have three commits in your repo, this is how they will look like, conceptually.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone wp-image-1165 size-large\" src=\"http:\/\/www.afternerd.com\/blog\/wp-content\/uploads\/2018\/12\/Screen-Shot-2018-12-29-at-5.18.49-PM-1024x606.png\" alt=\"\" width=\"1024\" height=\"606\" srcset=\"https:\/\/www.afternerd.com\/blog\/wp-content\/uploads\/2018\/12\/Screen-Shot-2018-12-29-at-5.18.49-PM-1024x606.png 1024w, https:\/\/www.afternerd.com\/blog\/wp-content\/uploads\/2018\/12\/Screen-Shot-2018-12-29-at-5.18.49-PM-300x178.png 300w, https:\/\/www.afternerd.com\/blog\/wp-content\/uploads\/2018\/12\/Screen-Shot-2018-12-29-at-5.18.49-PM-768x454.png 768w, https:\/\/www.afternerd.com\/blog\/wp-content\/uploads\/2018\/12\/Screen-Shot-2018-12-29-at-5.18.49-PM-200x118.png 200w, https:\/\/www.afternerd.com\/blog\/wp-content\/uploads\/2018\/12\/Screen-Shot-2018-12-29-at-5.18.49-PM-400x237.png 400w, https:\/\/www.afternerd.com\/blog\/wp-content\/uploads\/2018\/12\/Screen-Shot-2018-12-29-at-5.18.49-PM-600x355.png 600w, https:\/\/www.afternerd.com\/blog\/wp-content\/uploads\/2018\/12\/Screen-Shot-2018-12-29-at-5.18.49-PM-800x473.png 800w, https:\/\/www.afternerd.com\/blog\/wp-content\/uploads\/2018\/12\/Screen-Shot-2018-12-29-at-5.18.49-PM.png 1058w\" sizes=\"(max-width: 1024px) 100vw, 1024px\" \/><\/p>\n<p>But is it really a linked list though?<\/p>\n<p>Well read on and you will find out!<\/p>\n<h2 id=\"branch-out\">Step 2: Branch out<\/h2>\n<p>In fact, git allows you to branch out from the main branch (which is by default called the <strong>master<\/strong> branch).<\/p>\n<p>But why? What&#8217;s the point?<\/p>\n<p>Assume you have an idea of a new feature that will require a significant change\/refactoring to your existing code and you want to experiment with this idea without risking the stability of your existing codebase.<\/p>\n<p>One way to do that is to create a branch off of master and experiment with your idea risk-free.<\/p>\n<p>Branching is extremely useful especially when you are working on a project collaboratively because it allows individual developers to branch out and code away without stepping on each other&#8217;s feet.<\/p>\n<p>Let&#8217;s go back to our example and create a branch.<\/p>\n<p>To create a branch, you have to give it a name.<\/p>\n<p>Let&#8217;s call our new branch <strong>feature<\/strong>.<\/p>\n<p>Use the <span class=\"symbol\">git branch<\/span> command as follows<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-1167\" src=\"http:\/\/www.afternerd.com\/blog\/wp-content\/uploads\/2018\/12\/Screen-Shot-2018-12-29-at-5.35.06-PM.png\" alt=\"\" width=\"2562\" height=\"204\" srcset=\"https:\/\/www.afternerd.com\/blog\/wp-content\/uploads\/2018\/12\/Screen-Shot-2018-12-29-at-5.35.06-PM.png 2562w, https:\/\/www.afternerd.com\/blog\/wp-content\/uploads\/2018\/12\/Screen-Shot-2018-12-29-at-5.35.06-PM-300x24.png 300w, https:\/\/www.afternerd.com\/blog\/wp-content\/uploads\/2018\/12\/Screen-Shot-2018-12-29-at-5.35.06-PM-768x61.png 768w, https:\/\/www.afternerd.com\/blog\/wp-content\/uploads\/2018\/12\/Screen-Shot-2018-12-29-at-5.35.06-PM-1024x82.png 1024w, https:\/\/www.afternerd.com\/blog\/wp-content\/uploads\/2018\/12\/Screen-Shot-2018-12-29-at-5.35.06-PM-200x16.png 200w, https:\/\/www.afternerd.com\/blog\/wp-content\/uploads\/2018\/12\/Screen-Shot-2018-12-29-at-5.35.06-PM-400x32.png 400w, https:\/\/www.afternerd.com\/blog\/wp-content\/uploads\/2018\/12\/Screen-Shot-2018-12-29-at-5.35.06-PM-600x48.png 600w, https:\/\/www.afternerd.com\/blog\/wp-content\/uploads\/2018\/12\/Screen-Shot-2018-12-29-at-5.35.06-PM-800x64.png 800w, https:\/\/www.afternerd.com\/blog\/wp-content\/uploads\/2018\/12\/Screen-Shot-2018-12-29-at-5.35.06-PM-1200x96.png 1200w\" sizes=\"(max-width: 2562px) 100vw, 2562px\" \/><\/p>\n<p>Notice that the above command only creates a new branch but you are currently still on the master branch.<\/p>\n<p>In other words, any work you do and any commits you make will be added to the master branch, not the feature branch.<\/p>\n<p>To go from one branch to another, you use the <span class=\"symbol\">git checkout<\/span> command.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-1169\" src=\"http:\/\/www.afternerd.com\/blog\/wp-content\/uploads\/2018\/12\/Screen-Shot-2018-12-29-at-5.42.32-PM.png\" alt=\"\" width=\"2622\" height=\"284\" srcset=\"https:\/\/www.afternerd.com\/blog\/wp-content\/uploads\/2018\/12\/Screen-Shot-2018-12-29-at-5.42.32-PM.png 2622w, https:\/\/www.afternerd.com\/blog\/wp-content\/uploads\/2018\/12\/Screen-Shot-2018-12-29-at-5.42.32-PM-300x32.png 300w, https:\/\/www.afternerd.com\/blog\/wp-content\/uploads\/2018\/12\/Screen-Shot-2018-12-29-at-5.42.32-PM-768x83.png 768w, https:\/\/www.afternerd.com\/blog\/wp-content\/uploads\/2018\/12\/Screen-Shot-2018-12-29-at-5.42.32-PM-1024x111.png 1024w, https:\/\/www.afternerd.com\/blog\/wp-content\/uploads\/2018\/12\/Screen-Shot-2018-12-29-at-5.42.32-PM-200x22.png 200w, https:\/\/www.afternerd.com\/blog\/wp-content\/uploads\/2018\/12\/Screen-Shot-2018-12-29-at-5.42.32-PM-400x43.png 400w, https:\/\/www.afternerd.com\/blog\/wp-content\/uploads\/2018\/12\/Screen-Shot-2018-12-29-at-5.42.32-PM-600x65.png 600w, https:\/\/www.afternerd.com\/blog\/wp-content\/uploads\/2018\/12\/Screen-Shot-2018-12-29-at-5.42.32-PM-800x87.png 800w, https:\/\/www.afternerd.com\/blog\/wp-content\/uploads\/2018\/12\/Screen-Shot-2018-12-29-at-5.42.32-PM-1200x130.png 1200w\" sizes=\"(max-width: 2622px) 100vw, 2622px\" \/><\/p>\n<p>Now let&#8217;s modify the <strong>README<\/strong> file and create a commit in the feature branch.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-1170\" src=\"http:\/\/www.afternerd.com\/blog\/wp-content\/uploads\/2018\/12\/Screen-Shot-2018-12-29-at-6.07.48-PM.png\" alt=\"\" width=\"2046\" height=\"488\" srcset=\"https:\/\/www.afternerd.com\/blog\/wp-content\/uploads\/2018\/12\/Screen-Shot-2018-12-29-at-6.07.48-PM.png 2046w, https:\/\/www.afternerd.com\/blog\/wp-content\/uploads\/2018\/12\/Screen-Shot-2018-12-29-at-6.07.48-PM-300x72.png 300w, https:\/\/www.afternerd.com\/blog\/wp-content\/uploads\/2018\/12\/Screen-Shot-2018-12-29-at-6.07.48-PM-768x183.png 768w, https:\/\/www.afternerd.com\/blog\/wp-content\/uploads\/2018\/12\/Screen-Shot-2018-12-29-at-6.07.48-PM-1024x244.png 1024w, https:\/\/www.afternerd.com\/blog\/wp-content\/uploads\/2018\/12\/Screen-Shot-2018-12-29-at-6.07.48-PM-200x48.png 200w, https:\/\/www.afternerd.com\/blog\/wp-content\/uploads\/2018\/12\/Screen-Shot-2018-12-29-at-6.07.48-PM-400x95.png 400w, https:\/\/www.afternerd.com\/blog\/wp-content\/uploads\/2018\/12\/Screen-Shot-2018-12-29-at-6.07.48-PM-600x143.png 600w, https:\/\/www.afternerd.com\/blog\/wp-content\/uploads\/2018\/12\/Screen-Shot-2018-12-29-at-6.07.48-PM-800x191.png 800w, https:\/\/www.afternerd.com\/blog\/wp-content\/uploads\/2018\/12\/Screen-Shot-2018-12-29-at-6.07.48-PM-1200x286.png 1200w\" sizes=\"(max-width: 2046px) 100vw, 2046px\" \/><\/p>\n<h2><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-1171\" src=\"http:\/\/www.afternerd.com\/blog\/wp-content\/uploads\/2018\/12\/Screen-Shot-2018-12-29-at-6.11.21-PM.png\" alt=\"\" width=\"2758\" height=\"472\" srcset=\"https:\/\/www.afternerd.com\/blog\/wp-content\/uploads\/2018\/12\/Screen-Shot-2018-12-29-at-6.11.21-PM.png 2758w, https:\/\/www.afternerd.com\/blog\/wp-content\/uploads\/2018\/12\/Screen-Shot-2018-12-29-at-6.11.21-PM-300x51.png 300w, https:\/\/www.afternerd.com\/blog\/wp-content\/uploads\/2018\/12\/Screen-Shot-2018-12-29-at-6.11.21-PM-768x131.png 768w, https:\/\/www.afternerd.com\/blog\/wp-content\/uploads\/2018\/12\/Screen-Shot-2018-12-29-at-6.11.21-PM-1024x175.png 1024w, https:\/\/www.afternerd.com\/blog\/wp-content\/uploads\/2018\/12\/Screen-Shot-2018-12-29-at-6.11.21-PM-200x34.png 200w, https:\/\/www.afternerd.com\/blog\/wp-content\/uploads\/2018\/12\/Screen-Shot-2018-12-29-at-6.11.21-PM-400x68.png 400w, https:\/\/www.afternerd.com\/blog\/wp-content\/uploads\/2018\/12\/Screen-Shot-2018-12-29-at-6.11.21-PM-600x103.png 600w, https:\/\/www.afternerd.com\/blog\/wp-content\/uploads\/2018\/12\/Screen-Shot-2018-12-29-at-6.11.21-PM-800x137.png 800w, https:\/\/www.afternerd.com\/blog\/wp-content\/uploads\/2018\/12\/Screen-Shot-2018-12-29-at-6.11.21-PM-1200x205.png 1200w\" sizes=\"(max-width: 2758px) 100vw, 2758px\" \/><\/h2>\n<p>Now, let&#8217;s go back to master and inspect the <strong>README<\/strong> file<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-1172\" src=\"http:\/\/www.afternerd.com\/blog\/wp-content\/uploads\/2018\/12\/Screen-Shot-2018-12-29-at-6.15.01-PM.png\" alt=\"\" width=\"2400\" height=\"406\" srcset=\"https:\/\/www.afternerd.com\/blog\/wp-content\/uploads\/2018\/12\/Screen-Shot-2018-12-29-at-6.15.01-PM.png 2400w, https:\/\/www.afternerd.com\/blog\/wp-content\/uploads\/2018\/12\/Screen-Shot-2018-12-29-at-6.15.01-PM-300x51.png 300w, https:\/\/www.afternerd.com\/blog\/wp-content\/uploads\/2018\/12\/Screen-Shot-2018-12-29-at-6.15.01-PM-768x130.png 768w, https:\/\/www.afternerd.com\/blog\/wp-content\/uploads\/2018\/12\/Screen-Shot-2018-12-29-at-6.15.01-PM-1024x173.png 1024w, https:\/\/www.afternerd.com\/blog\/wp-content\/uploads\/2018\/12\/Screen-Shot-2018-12-29-at-6.15.01-PM-200x34.png 200w, https:\/\/www.afternerd.com\/blog\/wp-content\/uploads\/2018\/12\/Screen-Shot-2018-12-29-at-6.15.01-PM-400x68.png 400w, https:\/\/www.afternerd.com\/blog\/wp-content\/uploads\/2018\/12\/Screen-Shot-2018-12-29-at-6.15.01-PM-600x102.png 600w, https:\/\/www.afternerd.com\/blog\/wp-content\/uploads\/2018\/12\/Screen-Shot-2018-12-29-at-6.15.01-PM-800x135.png 800w, https:\/\/www.afternerd.com\/blog\/wp-content\/uploads\/2018\/12\/Screen-Shot-2018-12-29-at-6.15.01-PM-1200x203.png 1200w\" sizes=\"(max-width: 2400px) 100vw, 2400px\" \/><\/p>\n<p>As you can see, even though we have modified the <strong>README<\/strong> file in the feature branch, this modification is not reflected on the master branch.<\/p>\n<p>Both branches can be worked on completely separately from this point on.<\/p>\n<p>Since we are on the master branch, let&#8217;s create another commit here because why not?<\/p>\n<p>May be let&#8217;s just modify the<strong> hello.py<\/strong> file and make a new commit.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-1173\" src=\"http:\/\/www.afternerd.com\/blog\/wp-content\/uploads\/2018\/12\/Screen-Shot-2018-12-29-at-6.26.35-PM.png\" alt=\"\" width=\"2056\" height=\"732\" srcset=\"https:\/\/www.afternerd.com\/blog\/wp-content\/uploads\/2018\/12\/Screen-Shot-2018-12-29-at-6.26.35-PM.png 2056w, https:\/\/www.afternerd.com\/blog\/wp-content\/uploads\/2018\/12\/Screen-Shot-2018-12-29-at-6.26.35-PM-300x107.png 300w, https:\/\/www.afternerd.com\/blog\/wp-content\/uploads\/2018\/12\/Screen-Shot-2018-12-29-at-6.26.35-PM-768x273.png 768w, https:\/\/www.afternerd.com\/blog\/wp-content\/uploads\/2018\/12\/Screen-Shot-2018-12-29-at-6.26.35-PM-1024x365.png 1024w, https:\/\/www.afternerd.com\/blog\/wp-content\/uploads\/2018\/12\/Screen-Shot-2018-12-29-at-6.26.35-PM-200x71.png 200w, https:\/\/www.afternerd.com\/blog\/wp-content\/uploads\/2018\/12\/Screen-Shot-2018-12-29-at-6.26.35-PM-400x142.png 400w, https:\/\/www.afternerd.com\/blog\/wp-content\/uploads\/2018\/12\/Screen-Shot-2018-12-29-at-6.26.35-PM-600x214.png 600w, https:\/\/www.afternerd.com\/blog\/wp-content\/uploads\/2018\/12\/Screen-Shot-2018-12-29-at-6.26.35-PM-800x285.png 800w, https:\/\/www.afternerd.com\/blog\/wp-content\/uploads\/2018\/12\/Screen-Shot-2018-12-29-at-6.26.35-PM-1200x427.png 1200w\" sizes=\"(max-width: 2056px) 100vw, 2056px\" \/><\/p>\n<h2><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-1174\" src=\"http:\/\/www.afternerd.com\/blog\/wp-content\/uploads\/2018\/12\/Screen-Shot-2018-12-29-at-6.30.29-PM.png\" alt=\"\" width=\"2958\" height=\"468\" srcset=\"https:\/\/www.afternerd.com\/blog\/wp-content\/uploads\/2018\/12\/Screen-Shot-2018-12-29-at-6.30.29-PM.png 2958w, https:\/\/www.afternerd.com\/blog\/wp-content\/uploads\/2018\/12\/Screen-Shot-2018-12-29-at-6.30.29-PM-300x47.png 300w, https:\/\/www.afternerd.com\/blog\/wp-content\/uploads\/2018\/12\/Screen-Shot-2018-12-29-at-6.30.29-PM-768x122.png 768w, https:\/\/www.afternerd.com\/blog\/wp-content\/uploads\/2018\/12\/Screen-Shot-2018-12-29-at-6.30.29-PM-1024x162.png 1024w, https:\/\/www.afternerd.com\/blog\/wp-content\/uploads\/2018\/12\/Screen-Shot-2018-12-29-at-6.30.29-PM-200x32.png 200w, https:\/\/www.afternerd.com\/blog\/wp-content\/uploads\/2018\/12\/Screen-Shot-2018-12-29-at-6.30.29-PM-400x63.png 400w, https:\/\/www.afternerd.com\/blog\/wp-content\/uploads\/2018\/12\/Screen-Shot-2018-12-29-at-6.30.29-PM-600x95.png 600w, https:\/\/www.afternerd.com\/blog\/wp-content\/uploads\/2018\/12\/Screen-Shot-2018-12-29-at-6.30.29-PM-800x127.png 800w, https:\/\/www.afternerd.com\/blog\/wp-content\/uploads\/2018\/12\/Screen-Shot-2018-12-29-at-6.30.29-PM-1200x190.png 1200w\" sizes=\"(max-width: 2958px) 100vw, 2958px\" \/><\/h2>\n<p>Awesome.<\/p>\n<p>This is how the commits in our git repo look like now.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone wp-image-1175 size-large\" src=\"http:\/\/www.afternerd.com\/blog\/wp-content\/uploads\/2018\/12\/Screen-Shot-2018-12-29-at-6.37.02-PM-1024x710.png\" alt=\"\" width=\"1024\" height=\"710\" srcset=\"https:\/\/www.afternerd.com\/blog\/wp-content\/uploads\/2018\/12\/Screen-Shot-2018-12-29-at-6.37.02-PM-1024x710.png 1024w, https:\/\/www.afternerd.com\/blog\/wp-content\/uploads\/2018\/12\/Screen-Shot-2018-12-29-at-6.37.02-PM-300x208.png 300w, https:\/\/www.afternerd.com\/blog\/wp-content\/uploads\/2018\/12\/Screen-Shot-2018-12-29-at-6.37.02-PM-768x533.png 768w, https:\/\/www.afternerd.com\/blog\/wp-content\/uploads\/2018\/12\/Screen-Shot-2018-12-29-at-6.37.02-PM-200x139.png 200w, https:\/\/www.afternerd.com\/blog\/wp-content\/uploads\/2018\/12\/Screen-Shot-2018-12-29-at-6.37.02-PM-400x278.png 400w, https:\/\/www.afternerd.com\/blog\/wp-content\/uploads\/2018\/12\/Screen-Shot-2018-12-29-at-6.37.02-PM-600x416.png 600w, https:\/\/www.afternerd.com\/blog\/wp-content\/uploads\/2018\/12\/Screen-Shot-2018-12-29-at-6.37.02-PM-800x555.png 800w, https:\/\/www.afternerd.com\/blog\/wp-content\/uploads\/2018\/12\/Screen-Shot-2018-12-29-at-6.37.02-PM-1200x833.png 1200w, https:\/\/www.afternerd.com\/blog\/wp-content\/uploads\/2018\/12\/Screen-Shot-2018-12-29-at-6.37.02-PM.png 1476w\" sizes=\"(max-width: 1024px) 100vw, 1024px\" \/><\/p>\n<p>It is very obvious now that the commits do not form a linked list.<\/p>\n<p>It actually looks like a <a href=\"https:\/\/en.wikipedia.org\/wiki\/Tree_(data_structure)\" target=\"_blank\" rel=\"noopener noreferrer\">tree data structure<\/a>, right?<\/p>\n<p>Well in this particular case yes, but in the next step, you will see that it can be transformed into a more generic data structure.<\/p>\n<h2 id=\"merge-branches\">Step 3: Learn how to merge branches<\/h2>\n<p>There is no point in branching out without being able to merge branches back together.<\/p>\n<p>In our example above, the main reason we branched out was because we wanted to experiment with creating a new feature (which is in our case a dummy <strong>README<\/strong> modification :)).<\/p>\n<p>Now that we know that our feature is working, we want to merge this feature with the master branch.<\/p>\n<p>Git allows you to merge branches in various ways.<\/p>\n<p>But let&#8217;s use the simplest one, <span class=\"symbol\">git merge<\/span><\/p>\n<p>To merge the <strong>feature<\/strong> branch with the <strong>master<\/strong> branch, make sure you are on the <strong>master<\/strong> branch and then run the following command.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-1176\" src=\"http:\/\/www.afternerd.com\/blog\/wp-content\/uploads\/2018\/12\/Screen-Shot-2018-12-29-at-6.50.27-PM.png\" alt=\"\" width=\"2420\" height=\"250\" srcset=\"https:\/\/www.afternerd.com\/blog\/wp-content\/uploads\/2018\/12\/Screen-Shot-2018-12-29-at-6.50.27-PM.png 2420w, https:\/\/www.afternerd.com\/blog\/wp-content\/uploads\/2018\/12\/Screen-Shot-2018-12-29-at-6.50.27-PM-300x31.png 300w, https:\/\/www.afternerd.com\/blog\/wp-content\/uploads\/2018\/12\/Screen-Shot-2018-12-29-at-6.50.27-PM-768x79.png 768w, https:\/\/www.afternerd.com\/blog\/wp-content\/uploads\/2018\/12\/Screen-Shot-2018-12-29-at-6.50.27-PM-1024x106.png 1024w, https:\/\/www.afternerd.com\/blog\/wp-content\/uploads\/2018\/12\/Screen-Shot-2018-12-29-at-6.50.27-PM-200x21.png 200w, https:\/\/www.afternerd.com\/blog\/wp-content\/uploads\/2018\/12\/Screen-Shot-2018-12-29-at-6.50.27-PM-400x41.png 400w, https:\/\/www.afternerd.com\/blog\/wp-content\/uploads\/2018\/12\/Screen-Shot-2018-12-29-at-6.50.27-PM-600x62.png 600w, https:\/\/www.afternerd.com\/blog\/wp-content\/uploads\/2018\/12\/Screen-Shot-2018-12-29-at-6.50.27-PM-800x83.png 800w, https:\/\/www.afternerd.com\/blog\/wp-content\/uploads\/2018\/12\/Screen-Shot-2018-12-29-at-6.50.27-PM-1200x124.png 1200w\" sizes=\"(max-width: 2420px) 100vw, 2420px\" \/><\/p>\n<p>If you inspect both files now, you will see that the content of both branches have been merged.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-1177\" src=\"http:\/\/www.afternerd.com\/blog\/wp-content\/uploads\/2018\/12\/Screen-Shot-2018-12-29-at-6.53.22-PM.png\" alt=\"\" width=\"2268\" height=\"1010\" srcset=\"https:\/\/www.afternerd.com\/blog\/wp-content\/uploads\/2018\/12\/Screen-Shot-2018-12-29-at-6.53.22-PM.png 2268w, https:\/\/www.afternerd.com\/blog\/wp-content\/uploads\/2018\/12\/Screen-Shot-2018-12-29-at-6.53.22-PM-300x134.png 300w, https:\/\/www.afternerd.com\/blog\/wp-content\/uploads\/2018\/12\/Screen-Shot-2018-12-29-at-6.53.22-PM-768x342.png 768w, https:\/\/www.afternerd.com\/blog\/wp-content\/uploads\/2018\/12\/Screen-Shot-2018-12-29-at-6.53.22-PM-1024x456.png 1024w, https:\/\/www.afternerd.com\/blog\/wp-content\/uploads\/2018\/12\/Screen-Shot-2018-12-29-at-6.53.22-PM-200x89.png 200w, https:\/\/www.afternerd.com\/blog\/wp-content\/uploads\/2018\/12\/Screen-Shot-2018-12-29-at-6.53.22-PM-400x178.png 400w, https:\/\/www.afternerd.com\/blog\/wp-content\/uploads\/2018\/12\/Screen-Shot-2018-12-29-at-6.53.22-PM-600x267.png 600w, https:\/\/www.afternerd.com\/blog\/wp-content\/uploads\/2018\/12\/Screen-Shot-2018-12-29-at-6.53.22-PM-800x356.png 800w, https:\/\/www.afternerd.com\/blog\/wp-content\/uploads\/2018\/12\/Screen-Shot-2018-12-29-at-6.53.22-PM-1200x534.png 1200w\" sizes=\"(max-width: 2268px) 100vw, 2268px\" \/><\/p>\n<p>When you merge two branches using <span class=\"symbol\">git merge<\/span>, git actually creates a new commit that has two parents from both branches.<\/p>\n<p>That said, this is how the commit history looks like now.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone wp-image-1178 size-large\" src=\"http:\/\/www.afternerd.com\/blog\/wp-content\/uploads\/2018\/12\/Screen-Shot-2018-12-29-at-7.12.01-PM-1024x597.png\" alt=\"\" width=\"1024\" height=\"597\" srcset=\"https:\/\/www.afternerd.com\/blog\/wp-content\/uploads\/2018\/12\/Screen-Shot-2018-12-29-at-7.12.01-PM-1024x597.png 1024w, https:\/\/www.afternerd.com\/blog\/wp-content\/uploads\/2018\/12\/Screen-Shot-2018-12-29-at-7.12.01-PM-300x175.png 300w, https:\/\/www.afternerd.com\/blog\/wp-content\/uploads\/2018\/12\/Screen-Shot-2018-12-29-at-7.12.01-PM-768x448.png 768w, https:\/\/www.afternerd.com\/blog\/wp-content\/uploads\/2018\/12\/Screen-Shot-2018-12-29-at-7.12.01-PM-200x117.png 200w, https:\/\/www.afternerd.com\/blog\/wp-content\/uploads\/2018\/12\/Screen-Shot-2018-12-29-at-7.12.01-PM-400x233.png 400w, https:\/\/www.afternerd.com\/blog\/wp-content\/uploads\/2018\/12\/Screen-Shot-2018-12-29-at-7.12.01-PM-600x350.png 600w, https:\/\/www.afternerd.com\/blog\/wp-content\/uploads\/2018\/12\/Screen-Shot-2018-12-29-at-7.12.01-PM-800x466.png 800w, https:\/\/www.afternerd.com\/blog\/wp-content\/uploads\/2018\/12\/Screen-Shot-2018-12-29-at-7.12.01-PM-1200x699.png 1200w, https:\/\/www.afternerd.com\/blog\/wp-content\/uploads\/2018\/12\/Screen-Shot-2018-12-29-at-7.12.01-PM.png 1874w\" sizes=\"(max-width: 1024px) 100vw, 1024px\" \/><\/p>\n<p>Now it&#8217;s not a tree anymore, is it?<\/p>\n<p>Rather, it is a <a href=\"https:\/\/en.wikipedia.org\/wiki\/Directed_acyclic_graph\" target=\"_blank\" rel=\"noopener noreferrer\">DAG<\/a> (directed acyclic graph) with each commit pointing to its <strong>parent<\/strong> or <strong>parents<\/strong>.<\/p>\n<h2 id=\"resolve-conflicts\">Step 4: Learn how to resolve merge conflicts<\/h2>\n<p>Life is not always a bed of roses.<\/p>\n<p>Sometimes when you try to merge two branches, conflicts will happen.<\/p>\n<p>A <strong>conflict<\/strong> essentially means that two branches have modified the same part(s) of the same file(s).<\/p>\n<p>When this happens, git will prompt you to resolve the conflicts first before resuming the merge process.<\/p>\n<p>Needless to say, you have to be very careful about how you resolve these conflicts. Otherwise, bad things could happen.<\/p>\n<p>This is one of the areas where you can easily mess up if you don&#8217;t know what you&#8217;re doing.<\/p>\n<p>I have seen big chunks of code being destroyed after a merge process! This is not good for anyone, so don&#8217;t be that person \ud83d\ude42<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-1179\" src=\"http:\/\/www.afternerd.com\/blog\/wp-content\/uploads\/2018\/12\/2q0mum.jpg\" alt=\"\" width=\"507\" height=\"334\" srcset=\"https:\/\/www.afternerd.com\/blog\/wp-content\/uploads\/2018\/12\/2q0mum.jpg 507w, https:\/\/www.afternerd.com\/blog\/wp-content\/uploads\/2018\/12\/2q0mum-300x198.jpg 300w, https:\/\/www.afternerd.com\/blog\/wp-content\/uploads\/2018\/12\/2q0mum-200x132.jpg 200w, https:\/\/www.afternerd.com\/blog\/wp-content\/uploads\/2018\/12\/2q0mum-400x264.jpg 400w\" sizes=\"(max-width: 507px) 100vw, 507px\" \/><\/p>\n<h2 id=\"git-remotes\">Step 5: Get comfortable with git remotes<\/h2>\n<p>Congratulation, now you are ready to fiddle with Github \ud83d\ude42<\/p>\n<p>Finally the time has come.<\/p>\n<p>In addition to your local repo, git also allows you to have copies of your repo remotely.<\/p>\n<p>This is what <span class=\"symbol\">git remotes<\/span> are and Github is a service that allows you to host a remote git repo in the cloud.<\/p>\n<p><strong>But what&#8217;s the point of these remote repos anyways?<\/strong><\/p>\n<p>Well, from a disaster recovery perspective , the more copies of your repo the better. If you accidentally completely hose your local repo, you can still have access to your source code.<\/p>\n<p>From a collaboration perspective, this is where services like github and bitbucket shine.<\/p>\n<p>The remote copy of the repo can act as the shared, point-of-truth repo for you and your colleagues.<\/p>\n<p>Working collaboratively in this case entails pulling the source code from the remote repo to your local repo, doing your work locally, and then eventually pushing your work back to the remote repo.<\/p>\n<p>Let&#8217;s actually create a remote repo on Github for our example project.<\/p>\n<p><a href=\"https:\/\/github.com\/new\" target=\"_blank\" rel=\"noopener noreferrer\">Go to this link<\/a> and create a new repository <strong>helloworld<\/strong>.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"post-img alignnone wp-image-1199 size-full\" src=\"http:\/\/www.afternerd.com\/blog\/wp-content\/uploads\/2018\/12\/Screen-Shot-2018-12-30-at-8.08.20-AM.png\" alt=\"\" width=\"1584\" height=\"1420\" srcset=\"https:\/\/www.afternerd.com\/blog\/wp-content\/uploads\/2018\/12\/Screen-Shot-2018-12-30-at-8.08.20-AM.png 1584w, https:\/\/www.afternerd.com\/blog\/wp-content\/uploads\/2018\/12\/Screen-Shot-2018-12-30-at-8.08.20-AM-300x269.png 300w, https:\/\/www.afternerd.com\/blog\/wp-content\/uploads\/2018\/12\/Screen-Shot-2018-12-30-at-8.08.20-AM-768x688.png 768w, https:\/\/www.afternerd.com\/blog\/wp-content\/uploads\/2018\/12\/Screen-Shot-2018-12-30-at-8.08.20-AM-1024x918.png 1024w, https:\/\/www.afternerd.com\/blog\/wp-content\/uploads\/2018\/12\/Screen-Shot-2018-12-30-at-8.08.20-AM-200x179.png 200w, https:\/\/www.afternerd.com\/blog\/wp-content\/uploads\/2018\/12\/Screen-Shot-2018-12-30-at-8.08.20-AM-400x359.png 400w, https:\/\/www.afternerd.com\/blog\/wp-content\/uploads\/2018\/12\/Screen-Shot-2018-12-30-at-8.08.20-AM-600x538.png 600w, https:\/\/www.afternerd.com\/blog\/wp-content\/uploads\/2018\/12\/Screen-Shot-2018-12-30-at-8.08.20-AM-800x717.png 800w, https:\/\/www.afternerd.com\/blog\/wp-content\/uploads\/2018\/12\/Screen-Shot-2018-12-30-at-8.08.20-AM-1200x1076.png 1200w\" sizes=\"(max-width: 1584px) 100vw, 1584px\" \/><\/p>\n<p>This step creates an empty remote repository for you.<\/p>\n<p>It also tells you exactly how to push your local git repo to Github.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"post-img alignnone wp-image-1200 size-full\" src=\"http:\/\/www.afternerd.com\/blog\/wp-content\/uploads\/2018\/12\/Screen-Shot-2018-12-30-at-8.15.43-AM.png\" alt=\"\" width=\"1988\" height=\"1008\" srcset=\"https:\/\/www.afternerd.com\/blog\/wp-content\/uploads\/2018\/12\/Screen-Shot-2018-12-30-at-8.15.43-AM.png 1988w, https:\/\/www.afternerd.com\/blog\/wp-content\/uploads\/2018\/12\/Screen-Shot-2018-12-30-at-8.15.43-AM-300x152.png 300w, https:\/\/www.afternerd.com\/blog\/wp-content\/uploads\/2018\/12\/Screen-Shot-2018-12-30-at-8.15.43-AM-768x389.png 768w, https:\/\/www.afternerd.com\/blog\/wp-content\/uploads\/2018\/12\/Screen-Shot-2018-12-30-at-8.15.43-AM-1024x519.png 1024w, https:\/\/www.afternerd.com\/blog\/wp-content\/uploads\/2018\/12\/Screen-Shot-2018-12-30-at-8.15.43-AM-200x101.png 200w, https:\/\/www.afternerd.com\/blog\/wp-content\/uploads\/2018\/12\/Screen-Shot-2018-12-30-at-8.15.43-AM-400x203.png 400w, https:\/\/www.afternerd.com\/blog\/wp-content\/uploads\/2018\/12\/Screen-Shot-2018-12-30-at-8.15.43-AM-600x304.png 600w, https:\/\/www.afternerd.com\/blog\/wp-content\/uploads\/2018\/12\/Screen-Shot-2018-12-30-at-8.15.43-AM-800x406.png 800w, https:\/\/www.afternerd.com\/blog\/wp-content\/uploads\/2018\/12\/Screen-Shot-2018-12-30-at-8.15.43-AM-1200x608.png 1200w\" sizes=\"(max-width: 1988px) 100vw, 1988px\" \/><\/p>\n<p>Since we already have a local git repo, let&#8217;s push it upstream to Github.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-1201\" src=\"http:\/\/www.afternerd.com\/blog\/wp-content\/uploads\/2018\/12\/Screen-Shot-2018-12-30-at-8.20.59-AM.png\" alt=\"\" width=\"2794\" height=\"754\" srcset=\"https:\/\/www.afternerd.com\/blog\/wp-content\/uploads\/2018\/12\/Screen-Shot-2018-12-30-at-8.20.59-AM.png 2794w, https:\/\/www.afternerd.com\/blog\/wp-content\/uploads\/2018\/12\/Screen-Shot-2018-12-30-at-8.20.59-AM-300x81.png 300w, https:\/\/www.afternerd.com\/blog\/wp-content\/uploads\/2018\/12\/Screen-Shot-2018-12-30-at-8.20.59-AM-768x207.png 768w, https:\/\/www.afternerd.com\/blog\/wp-content\/uploads\/2018\/12\/Screen-Shot-2018-12-30-at-8.20.59-AM-1024x276.png 1024w, https:\/\/www.afternerd.com\/blog\/wp-content\/uploads\/2018\/12\/Screen-Shot-2018-12-30-at-8.20.59-AM-200x54.png 200w, https:\/\/www.afternerd.com\/blog\/wp-content\/uploads\/2018\/12\/Screen-Shot-2018-12-30-at-8.20.59-AM-400x108.png 400w, https:\/\/www.afternerd.com\/blog\/wp-content\/uploads\/2018\/12\/Screen-Shot-2018-12-30-at-8.20.59-AM-600x162.png 600w, https:\/\/www.afternerd.com\/blog\/wp-content\/uploads\/2018\/12\/Screen-Shot-2018-12-30-at-8.20.59-AM-800x216.png 800w, https:\/\/www.afternerd.com\/blog\/wp-content\/uploads\/2018\/12\/Screen-Shot-2018-12-30-at-8.20.59-AM-1200x324.png 1200w\" sizes=\"(max-width: 2794px) 100vw, 2794px\" \/><\/p>\n<p>And there you go.<\/p>\n<p>You just pushed your local repo remotely.<\/p>\n<p>Now you have two copies of your local repo.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"post-img alignnone wp-image-1202 size-full\" src=\"http:\/\/www.afternerd.com\/blog\/wp-content\/uploads\/2018\/12\/Screen-Shot-2018-12-30-at-8.22.10-AM.png\" alt=\"\" width=\"2004\" height=\"1186\" srcset=\"https:\/\/www.afternerd.com\/blog\/wp-content\/uploads\/2018\/12\/Screen-Shot-2018-12-30-at-8.22.10-AM.png 2004w, https:\/\/www.afternerd.com\/blog\/wp-content\/uploads\/2018\/12\/Screen-Shot-2018-12-30-at-8.22.10-AM-300x178.png 300w, https:\/\/www.afternerd.com\/blog\/wp-content\/uploads\/2018\/12\/Screen-Shot-2018-12-30-at-8.22.10-AM-768x455.png 768w, https:\/\/www.afternerd.com\/blog\/wp-content\/uploads\/2018\/12\/Screen-Shot-2018-12-30-at-8.22.10-AM-1024x606.png 1024w, https:\/\/www.afternerd.com\/blog\/wp-content\/uploads\/2018\/12\/Screen-Shot-2018-12-30-at-8.22.10-AM-200x118.png 200w, https:\/\/www.afternerd.com\/blog\/wp-content\/uploads\/2018\/12\/Screen-Shot-2018-12-30-at-8.22.10-AM-400x237.png 400w, https:\/\/www.afternerd.com\/blog\/wp-content\/uploads\/2018\/12\/Screen-Shot-2018-12-30-at-8.22.10-AM-600x355.png 600w, https:\/\/www.afternerd.com\/blog\/wp-content\/uploads\/2018\/12\/Screen-Shot-2018-12-30-at-8.22.10-AM-800x473.png 800w, https:\/\/www.afternerd.com\/blog\/wp-content\/uploads\/2018\/12\/Screen-Shot-2018-12-30-at-8.22.10-AM-1200x710.png 1200w\" sizes=\"(max-width: 2004px) 100vw, 2004px\" \/><\/p>\n<h2>Final words<\/h2>\n<p>Now you have a bird&#8217;s eye view of what git is, what Github is, and how to go about learning them and in what order.<\/p>\n<p>It is really important, and expected, in this day and age for any software engineer to be a git master.<\/p>\n<p>From here, it is up to you to dive deeper and learn each of the concepts above in great depth.<\/p>\n<p>Good luck \ud83d\ude42<\/p>\n<h2>Featured Posts<\/h2>\n<ul>\n<li><a href=\"https:\/\/www.afternerd.com\/blog\/learn-python\/\">The Python Learning Path (From Beginner to Mastery)<\/a><\/li>\n<li><a href=\"https:\/\/www.afternerd.com\/blog\/learn-computer-science\/\">Learn Computer Science (From Zero to Hero)<\/a><\/li>\n<li><a href=\"https:\/\/www.afternerd.com\/blog\/coding-interview\/\">Coding Interview Preparation Guide<\/a><\/li>\n<li><a href=\"https:\/\/www.afternerd.com\/blog\/stock-investing-for-beginners\/\">The Programmer&#8217;s Guide to Stock Market Investing<\/a><\/li>\n<li><a href=\"https:\/\/www.afternerd.com\/blog\/start-programming-blog\/\">How to Start Your Programming Blog?<\/a><\/li>\n<\/ul>\n<div class=\"after-post-box\">\n<h2>Are you Beginning your Programming Career?<\/h2>\n<h3>I provide my best content for beginners in the newsletter.<\/h3>\n<ul>\n<li>Python tips for beginners, intermediate, and advanced levels.<\/li>\n<li>CS Career tips and advice.<\/li>\n<li>Special discounts on my premium courses when they launch.<\/li>\n<\/ul>\n<p>And so much more&#8230;<\/p>\n<h3>Subscribe now. It&#8217;s Free.<\/h3>\n<p><script type=\"text\/javascript\" src=\"\/\/mautic.afternerd.com\/form\/generate.js?id=2\"><\/script><\/p>\n<\/div>\n\n","protected":false},"excerpt":{"rendered":"","protected":false},"author":1,"featured_media":1181,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[12],"tags":[1049],"yst_prominent_words":[1023,39,1004,1014,1025,1081,1045,1044,981,990,1046,1047,1048,1065,1024,991,1010,995,1080,1079],"_links":{"self":[{"href":"https:\/\/www.afternerd.com\/blog\/wp-json\/wp\/v2\/posts\/1152"}],"collection":[{"href":"https:\/\/www.afternerd.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.afternerd.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.afternerd.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.afternerd.com\/blog\/wp-json\/wp\/v2\/comments?post=1152"}],"version-history":[{"count":17,"href":"https:\/\/www.afternerd.com\/blog\/wp-json\/wp\/v2\/posts\/1152\/revisions"}],"predecessor-version":[{"id":1545,"href":"https:\/\/www.afternerd.com\/blog\/wp-json\/wp\/v2\/posts\/1152\/revisions\/1545"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.afternerd.com\/blog\/wp-json\/wp\/v2\/media\/1181"}],"wp:attachment":[{"href":"https:\/\/www.afternerd.com\/blog\/wp-json\/wp\/v2\/media?parent=1152"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.afternerd.com\/blog\/wp-json\/wp\/v2\/categories?post=1152"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.afternerd.com\/blog\/wp-json\/wp\/v2\/tags?post=1152"},{"taxonomy":"yst_prominent_words","embeddable":true,"href":"https:\/\/www.afternerd.com\/blog\/wp-json\/wp\/v2\/yst_prominent_words?post=1152"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}