<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Nilay Majorwar on Medium]]></title>
        <description><![CDATA[Stories by Nilay Majorwar on Medium]]></description>
        <link>https://medium.com/@nilaymajorwar?source=rss-ad9289b653f0------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*IgqiUH2xOlLXk3JTFk2iDg.jpeg</url>
            <title>Stories by Nilay Majorwar on Medium</title>
            <link>https://medium.com/@nilaymajorwar?source=rss-ad9289b653f0------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Mon, 23 Nov 2026 06:18:24 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@nilaymajorwar/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[A Guide to Git: Remotes and GitHub]]></title>
            <link>https://medium.com/programming-club-iit-kanpur/a-guide-to-git-remotes-and-github-a6770c741a11?source=rss-ad9289b653f0------2</link>
            <guid isPermaLink="false">https://medium.com/p/a6770c741a11</guid>
            <category><![CDATA[programming]]></category>
            <category><![CDATA[version-control]]></category>
            <category><![CDATA[github]]></category>
            <category><![CDATA[git]]></category>
            <category><![CDATA[beginners-guide]]></category>
            <dc:creator><![CDATA[Nilay Majorwar]]></dc:creator>
            <pubDate>Wed, 10 Feb 2021 10:54:34 GMT</pubDate>
            <atom:updated>2021-02-11T07:21:44.232Z</atom:updated>
            <content:encoded><![CDATA[<h3>A Guide to Git: Remotes, Rebasing and GitHub</h3><p>In the <a href="https://medium.com/programming-club-iit-kanpur/a-guide-to-git-branches-and-merging-ae27f6b72f3b">last part</a>, we learnt about the most important concepts in Git — branches and more importantly, merging one branch into another. These concepts extend a lot into the more practical aspects of using Git, including what we will learn about in this part of the guide: GitHub and remote repositories.</p><p>Till now, when it comes to collaboration, we’ve considered situations where multiple users are working on the same Git repository. But as some of you may have wondered, this is not really a common thing to happen at all, because this means having project members on the same computer!</p><h3>Remote repositories and GitHub</h3><p>So to facilitate collaboration among people regardless of where they are, we have <strong>remote repositories</strong>. As the name says, these are repositories that do not exist on the user’s file system and are generally stored in the cloud. If you appreciate the cloud facilities of Google Docs for seamless collaboration in comparison to working on offline Word files, remote repositories are roughly the same thing.</p><p>You must have heard of GitHub. If you ask someone what it is, they may say it is a place to host your projects, for collaboration purposes or just as cloud storage — and that is a valid definition for all practical purposes. But at the metal, GitHub is really just Google Drive for Git repositories. It allows users to create and manage Git repositories on the cloud (with some additional features for easy collaboration). <strong>GitHub is simply a hub for Git repositories.</strong></p><p>Since remote repositories are (generally) hosted such that they are accessible over the Internet (or some private network), every remote Git repository has a URL that ends with .git. A repository hosted on GitHub will have a URL like <a href="https://github.com/johndoe/some-repo.git.">https://github.com/johndoe/some-repo.git.</a></p><h3>Getting set up</h3><p>Since this one deals with remote repositories, you’ll need a bit more of set up. All of the below steps are point-and-click really, so I’m not providing any detailed instructions — if you can create an account on Facebook, this shouldn’t be too tough.</p><ol><li>Create an account on GitHub. Free tip: Keep your username short and all lowercase. It doesn’t have to be your name.</li><li>Create a repository called poems. Ensure that the repository is set to public, and do not select any of the options under &quot;Initialize this repository with&quot;.</li></ol><p>Beyond this point, I’ll assume your username is “john”. Replace it with your username in commands you execute.</p><h3>The Plan</h3><p>Okay, so we’ve actually created a remote repository called poems on GitHub, which will act as a cloud backup of our book. Here&#39;s the plan we&#39;re going to follow in this part:</p><ol><li>Our cloud version is currently a bare repository with no content, so we’ll <strong>push</strong> our current progress to the remote repository.</li><li>We will create a commit directly on the cloud (this will represent a co-author’s change), and then try to <strong>pull</strong> this change to our local repository.</li><li>We will learn a bit about <strong>rebasing</strong>, a very powerful tool that must be used with care because its effects can be irreversible.</li></ol><h3>Adding remotes</h3><p>The general workflow of dealing with remote repositories is to work on your local repository while being able to sync changes with relevant remote repositories to collaborate with others. To “link” remote repositories to your local Git repository, we use <strong>remotes</strong>. In simple terms, a remote is a nickname for the URL of a remote repository. Here’s how you add a remote to your local repository:</p><pre><strong># Add a remote repository<br># Syntax: </strong>git remote add &lt;remote-name&gt; &lt;repo-url&gt;<br>git remote add origin &lt;https://github.com/john/poems.git&gt;</pre><p>Here, we added a remote called origin to our local repository, that links to the remote repository we just created on GitHub. The URL we used can be obtained from the top section of your repository homepage (make sure you select HTTPS instead of SSH).</p><blockquote>You can also delete remotes by a similar command:</blockquote><blockquote>git remote remove &lt;remote-name&gt;</blockquote><p>Although you can name a branch anything you want, origin is almost ubiquitously used for a remote repository that acts as the cloud version of a local repository. Similarly, upstream is a commonly used term to refer to the main repository while contributing to an open source project.</p><h3>Pushing changes</h3><p>Now that our local repository is linked to the remote repository, we can move forward and push all our work done on master up till now to the remote repository and update it.</p><pre><strong># Push &quot;master&quot; branch to remote &quot;origin&quot;<br># Syntax: git push &lt;remote-name&gt; &lt;branch-name&gt;</strong><br>git push origin master</pre><p>This will push all your commits on master to the remote repository. In simpler terms, this means the master branch of your remote repository now has all the commits made on your local master branch. That&#39;s all git push does - it sends work from one repository to another.</p><p>If your network is fine, the command should work without any problem. To confirm it worked, just go to your repository home and it should show all the poem*.txt files you wrote. You can also view your commit history and read file contents there.</p><h3>A short detour: tags</h3><p>Tags are, as their name says, tags attached to certain commits for the purpose of tracking branches or bookmarking commits. When you execute git log, you may have noticed stuff like master or add-headings in brackets after some commits. Those are really tags that keep track of where each branch is (remember, branches are just nicknames for commits - do you see a similarity between tags and branches?)</p><h3>Making commits directly on remote repositories</h3><p>I know, the next step in the plan was to pull changes from the remote repository, but for that we need a small hack. To pull changes, you’d actually need some changes in the remote repository that your local repository is not aware of.</p><p>Since I don’t want the mess of getting you to get someone else to make a commit on your repository, we will take the shortcut and once again, you’ll have to make a commit that actually represents someone else’s commit. This time, we’ll add a README file to our cloud repository.</p><p>So go to your repository homepage, click on “Add a README” and write a summary of your repository. You’ll also have to write a commit message (and an optional description) there, and check the option of committing directly to master branch. Once you&#39;re done, your remote repository should be a commit ahead of your local repository. That&#39;s all we need in this section.</p><p><strong>Important:</strong> This web version of making commits is not intended for regular use. If you have a local repository with remote set, pushing a local commit is always considered better than a direct commit to the remote repository. Use the direct method only when really necessary.</p><h3>Pulling changes</h3><p>Finally, the main task. Now that our remote repository is ahead of our local repository, we can try to fetch these changes to our local repository. Let’s do it:</p><pre><strong># Fetch changes to local repository</strong><br>git fetch origin master</pre><p>This <strong>fetches</strong> changes from branch master of the remote repository at origin to your local repository. Note that this is only the first part of getting changes: fetching only tells Git about the current status of a remote branch, and does not affect the actual commit tree of your local repository. These fetched branches can be referred as with the syntax remote/branch. Let&#39;s go on to actually merge these changes into our local master branch:</p><pre><strong># Merge fetched changes into local branch</strong><br>git checkout master<br>git merge origin/master</pre><p>This part should feel similar — it’s just what we did in the last part, merging one branch into another. With this command, now your local master branch should be up-to-date, with the README file that you added directly to the cloud repository.</p><p>Turns out fetching and merging like this is a very common Git operation, so there’s a very comfortable shorthand:</p><pre><strong># Pull changes from remote repository</strong><br>git pull origin master</pre><p>This command is simply a combination of the above two operations. It fetches changes from the remote repository and merges (or tries to) them into the local repository. This is what you’ll probably use in your day-to-day Git tasks, instead of manually fetching and merging.</p><h3>Merge conflicts, again</h3><p>If you were following this guide very closely up till now, you might have realised that the above push and pull operations may not be completely successful all the time. Why? Because wherever you have a branch merging into another, there is always the possibility of a merge conflict, arising from diverged paths.</p><p>While push operations are rejected straightaway on diverged paths, pull operations allow you to resolve any conflicts that arise in the merge stage. Everything is the same — a merge commit is created that acts as the combination of all changes done on the remote branch, and any clashes between local work and work on remote will be marked by Git as before.</p><p>But if your local work consists of only a few not-too-big commits, there’s a neater way to update your local branch — rebase pulls.</p><h3>Rebasing branches</h3><p>Rebasing is a very powerful Git operation that allows you to clean up your commit tree and make it look more linear and less merge-y. It is basically an alternative merge strategy to the three-way-merge we learnt earlier, that tries to make the feature branch look like it was based off of the current state of the target branch — thus changing the base of a branch, or <strong>rebasing</strong> it.</p><p>It is particularly super-useful when there has been some <strong>work on the main branch that affects work you’re doing on your feature branch</strong>. In these cases, rebasing allows you to update your branch as well as adjusting your commits to the work done on the main branch.</p><p>Let’s properly understand how rebasing works. Assume a repository with the following commit tree having two branches.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/737/0*CnYerAJhkvdeMl7g" /></figure><p>We want to merge the feature branch into the target branch through the rebase strategy. Before we see in detail how the rebase strategy works, have a look at what the three-way-merge strategy resulted in, for contrast:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/875/0*8OueABVHYXIlYAvU" /></figure><p>While three-way-merge works fine, it leads to a slightly more complicated and non-linear commit history due to all the merge commits. They’re worth the effort for large merges, but the rebase strategy is much better for smaller ones.</p><p>The idea of a rebase is to edit the feature branch so that it looks like the following:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1000/0*fSD3uGYE34ekLUQ7" /></figure><p>Much cleaner, right? Since the feature branch is now based on the <em>current</em> target branch, merging is just a fast-forward and won’t have any merge conflicts at all. Here’s the command to rebase the feature branch onto the target branch:</p><pre><strong># Switch to &quot;feature&quot; branch</strong><br>git checkout feature<br><strong># Rebase current branch onto &quot;target&quot; branch</strong><br>git rebase target</pre><pre><strong># OR without checkout, simply...</strong><br>git rebase feature target</pre><p>Referring to the example in the above diagrams, here are the <strong>three stages of a rebase:</strong></p><ol><li>For some time, cut out commits D and E from the feature branch and keep them aside.</li><li>Copy commits B and C from target branch onto the feature branch.</li><li>Put commits D and E back onto the feature branch so that they now happen after B and C.</li></ol><blockquote>Technically, the final commits D and E are not carbon-copies of the initial commits, but only have the same file changes and commit metadata (message, author, etc). This is because the calculation of the commit hash (a long unique hex string) involves previous commits too. Since the previous commits of D and E change after the rebase, their hashes will be different and thus the final commits D and E are often represented as D’ and E’.</blockquote><h3>Merge conflicts in rebasing</h3><p>The rebase strategy of merging branches involves merge conflicts too, but here things are somewhat different. Merge conflicts arise in the third stage of the rebase, when commits D and E are one-by-one replaced onto the feature branch. Since the initial state of the files are different, replacing the commits may or may not make total sense — when they don’t, you get a merge conflict.</p><p>We won’t try it here for the sake of brevity, but you should definitely try it yourself. It’s not too different from usual merge conflicts, but take care of the following points:</p><ul><li>Once you’ve made changes to resolve the conflict blocks, <strong>do not commit</strong> as you did before: instead, run git rebase --continue for Git to continue with the remaining commits.</li><li>You may have to go through resolving conflicts for every commit made on your feature branch. This is because feature branch commits (D and E, above) are replaced one-by-one, and each replacement may lead to conflicts. In fact, this is a major reason why the rebase-merge strategy is not preferred for large merges.</li></ul><blockquote><em>⚠️</em> Rebasing is often an irreversible process and should be done with caution. If you mess something up at any point of the rebase, execute git rebase --abort to cancel the rebase and start over. Also, never <strong>ever</strong> do a rebase on a public branch - rebasing rewrites history which makes things very, very complicated for other people working on the branch.</blockquote><h3>Rebase pulls</h3><p>Returning to the main topic, let’s see how to pull from remote branches with the rebase strategy. Rebase pulls are nothing but normal pulls but the merge strategy used for the second stage of pull is rebase-merge instead of the default three-way-merge. As mentioned above, this is useful to update your local branch with work done on a remote branch, while being able to adjust your local commits. Here’s how you’d do a rebase pull from the master branch of origin remote:</p><pre><strong># Pull with rebase</strong><br>git pull --rebase origin master</pre><p>This will do the following:</p><ol><li>Fetch the branch origin/master</li><li>Rebase current branch onto origin/master</li></ol><p>Note that no merge commits are made here — your branch gets updated to include the work done on origin/master, that&#39;s all.</p><h3>The general GitHub workflow</h3><p>Now that you know how to deal with remote repositories and collaborate with other people, it may be useful to have a general idea about how people collaborate on GitHub.</p><p>Let us imagine a project, led by person X. This leader has full access to the GitHub repository for the project, in particular including the ability to merge other people’s work into the repository (we’ll see in a short while how). There are other contributors to the project, who do not have administrative access to the GitHub repository.</p><p>Assume you want to start contributing to the project. Let’s have a look at what you’d have to do:</p><h3>Fork the project</h3><p>Firstly, you’ll fork the repository. This simply means copying the GitHub repository over to your own account, much like “make a copy” on Google Docs. This forked repository acts as the cloud backup of your work on the project, but more importantly it acts as the origin of your pull requests — we’ll see that later.</p><p>A GitHub repository can be forked by going to the repository page on GitHub and clicking on the “Fork” button in the top-right. This will create a repository in your account, which will be a replica of the main repository.</p><h3>Clone, add remotes and play around</h3><p>Cloning is a very common action — cloning a GitHub repository means making a <strong>local</strong> copy of the GitHub repository. It’s the Git equivalent to downloading the project code.</p><p>To clone your forked repository:</p><ol><li>Click on the green “Code” dropdown and select HTTPS.</li><li>Copy the link shown.</li><li>On a terminal, execute:</li></ol><pre><strong># Clone repository via HTTPS URL </strong><br>git clone &lt;copied-url&gt;</pre><p>This will create a directory with the same name as the repository in your current working directory. Inside, you’ll find a local copy of the project repository.</p><p>Next, you should add some remotes for the GitHub repositories — both the main project and your fork. Normally you call the fork as origin and the main project repository as upstream. So add the remotes as follows:</p><pre><strong># Add remotes for the GitHub repositories</strong><br>git remote add origin &lt;https://github.com/john/project.git&gt;<br>git remote add upstream &lt;https://github.com/X/project.git&gt;</pre><p>Now play around with the project code, or do whatever work you wanted to do with the code. If you’re interested in fixing an issue with the project, the Issues tab on the main repository’s page generally lists issues that currently exist in the project.</p><p>Let us say you made some changes that fix an existing issue in the project. Ideally any work should be done in a dedicated branch, so let’s assume you did your work in the branch fix-issue. Now your next step is to actually submit your changes to the main project repository.</p><h3>Pull and push</h3><p>Before you start submitting your changes, you should check if any work was done on the main repository, and update your branch. Depending on how much work you’ve done, you can opt for a normal pull or a rebase pull:</p><pre><strong># WHILE on branch &quot;fix-issue&quot;,<br># Normal pull, if your work is large (tens of commits)</strong><br>git pull origin master<br><strong># Rebase pull, if your work is not much (few commits)</strong><br>git pull --rebase origin master</pre><p>You may have to resolve any conflicts, obviously.</p><p>Once you’re done, push your changes on branch fix-issue to your fork:</p><pre><strong># Push your changes to origin</strong><br>git push origin fix-issue</pre><p>Great job, you’ve now pushed your changes to your fork on GitHub. All that remains is to submit a “pull request”.</p><h3>Pull requests</h3><p>Pull requests are horribly named, and indeed the name often confuses beginners as to what their job is. A better name is “merge request” — these are basically requests to the owner or leader of the project to merge some work into the project. A pull request consists of the commits and file changes made by you along with a description of the work done. GitHub also allows people to comment and review the pull request, deciding if the work done is okay to be merged.</p><p>To make a pull request:</p><ol><li>Go to the main repository’s page and open the “Pull requests” tab.</li><li>Click on the green “New pull request” button and then click on “compare across forks” (in the text, right below the heading “Compare changes”).</li><li>In the right part, select your fork and the branch fix-issue. Click on the green &quot;Create pull request&quot; button.</li><li>Enter the title and description of the pull request, and create the pull request. It is good practice to give a detailed description of your work done.</li></ol><p>Now, the leader of the project can see your work done and once it is approved, the leader can merge it into the project.</p><p>The following illustration sums up the above pretty well:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/997/1*kXNnAzS4MVQpxveaODyYoQ.png" /></figure><h3>Summary</h3><p>In this part, we covered the concepts of remote repositories and how to sync progress between local and remote repositories, finishing with a short tour of GitHub. To summarise:</p><ul><li>Remote repositories are just Git repositories hosted on the cloud. The most popular cloud provider for Git repositories is GitHub.</li><li>You can push and pull work to and from remote repositories to sync work between local and remote repositories.</li><li>Rebasing is a powerful tool that allows you to update your branch with work done on the main branch, so that the resultant commit tree is linear and easy to manage.</li><li>GitHub has features that facilitate collaboration in projects between lots of people.</li></ul><p>This is the last part of the guide. We covered a lot of topics, and I hope this guide was helpful to people new to Git, and programming in general. There is a lot more to Git than this guide covered — <a href="https://learngitbranching.js.org/">Learn Git Branching</a> is an absolutely brilliant way to learn and get hands-on experience on that. (Thanks <a href="https://medium.com/u/5cb2bbe1b2b9">Abhishek Shree</a> for the suggestion!)</p><p>Feel free to suggest any fixes and improvements!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=a6770c741a11" width="1" height="1" alt=""><hr><p><a href="https://medium.com/programming-club-iit-kanpur/a-guide-to-git-remotes-and-github-a6770c741a11">A Guide to Git: Remotes and GitHub</a> was originally published in <a href="https://medium.com/programming-club-iit-kanpur">Programming Club, IIT Kanpur</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[A Guide to Git: Branches and Merging]]></title>
            <link>https://medium.com/programming-club-iit-kanpur/a-guide-to-git-branches-and-merging-ae27f6b72f3b?source=rss-ad9289b653f0------2</link>
            <guid isPermaLink="false">https://medium.com/p/ae27f6b72f3b</guid>
            <category><![CDATA[programming]]></category>
            <category><![CDATA[git]]></category>
            <category><![CDATA[version-control]]></category>
            <dc:creator><![CDATA[Nilay Majorwar]]></dc:creator>
            <pubDate>Sun, 17 Jan 2021 06:33:36 GMT</pubDate>
            <atom:updated>2021-01-19T12:27:34.211Z</atom:updated>
            <content:encoded><![CDATA[<p>In <a href="https://medium.com/programming-club-iit-kanpur/a-guide-to-git-the-fundamentals-2d3db6b4df53">Part 1</a>, we covered initializing a Git repository, staging our changes, committing our work and checking out past versions of our project. We also took a little dive into the backstage of how the above operations happen inside Git.</p><p>This time, we’ll cover some of the more complex concepts and operations of Git — in particular, we’ll dive into how commits are organised inside Git and have a go at using branches and merging them. We’ll be focusing a bit more on theory this time, so follow closely.</p><h3>Git and Collaboration</h3><p>Till now, we’ve used Git simply as a personal book-keeping butler, ignoring one of the most important use cases of a powerful version control system — collaboration. Version control systems are built to allow seamless and nearly painless collaboration between members of a project. Linus Torvalds developed Git when BitKeeper failed to keep pace with the rapidly growing Linux development community and the kernel project itself (amongst some other reasons).</p><p>One of the features of version control systems that allow for easy collaboration are branches, which we’ll be covering in this part. So from now, we’ll assume that we are working with some other authors too on our novel.</p><h3>Branching</h3><p>Our book’s going pretty good, but we forgot something — we didn’t add headings on any of our poems! Normally, we would just add headings to our existing files and make a commit for it. But now that we are working with other people too, we need to ensure we don’t get in the way of others.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/800/0*DZAkWeLNmlabayDL.png" /><figcaption>An example of a project extensively using Git branches. Different colours denote different branches, and asterisks are points where one branch merges into another. This’ll look simpler by the end of the article.</figcaption></figure><p>When people collaborate, it is good practice to keep your work in a separate space to avoid clash of work (imagine five people writing an article on the same piece of paper). The general workflow is to create a separate space for your task, do your task in this space and when done, merge your space into the main line. In Git, this is done via “branches”. Let’s try it.</p><p>Here, the task we want to do is to add headings to our existing poems. So we’ll name the branch as add-headings (branch names should not contain spaces). If you’re here from part 1, be sure to checkout to the current, latest version.</p><pre><strong># Checkout to current version<br></strong>git checkout master</pre><pre><strong># Create a new branch for adding headings</strong><br>git branch add-headings</pre><pre><strong># Switch to the branch we just created</strong><br>git checkout add-headings</pre><p>Fair enough. Now we’ve created a branch and switched to it, so that our active branch is add-headings. Let&#39;s actually add our headings now and commit the changes. Open each poem file and add a heading at the top of the contents.</p><pre><strong><em># DIY:</em></strong><em> </em><strong>Add a heading to each poem</strong><br><strong><em># THEN</em></strong><em>, </em><strong>commit the changes:</strong><br>git add .<br>git commit -m &quot;Add poem headings&quot;</pre><p>Note how we staged changes from all the existing files using git add .. The character .(period) stands for the current directory in Bash and other shells, so the command basically means &quot;stage all changes in the current directory&quot;. Also, this commit will be added on the new branch we created.</p><p>Great, so you just created a new branch and committed some work to it. Branches are simply a way to create parallel lines of work. Besides direct collaboration, they are often used to:</p><ul><li>Work on and track progress of several tasks in parallel</li><li>Separate stable and unstable versions of a project</li><li>Maintain utility stuff like project websites in a separate branch</li></ul><h3>What’s underneath?</h3><p>In the first part, we just dealt with commits like it’s a straight line of dominoes. But now, branches change that — now this straight line seems to split and diverge. This leads us to the million-dollar question: how are commits organised in Git?</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/802/0*M8YPn_FFcG5OCB16" /></figure><p>Formally, one would say they are organised in the form of a tree, where each commit has a certain “parent” commit that roughly translates to the previous commit. But you may like a simpler analogy — let’s say we’re exploring a forest, and dirt paths magically appear wherever we walk. Whenever we commit, we set down a flag in the ground.</p><p>So, when we start out in the forest, we create the main path that represents the current state of the project. This main path represents the branch master, and on every commit we set down a flag. When we created a new branch for a side task, we basically decided to take a detour onto a dirt path on the side, called add-headings.</p><blockquote>Actually, a branch is simply an alias, or a nickname, for a commit. So, add-headings is just a nickname for the commit &quot;Add poem 3&quot;, and similarly for master. Maybe now you can realise that the two &quot;variants&quot; of the checkout command - one for checking out commits, and one for switching branches - are actually the same thing, only referring to commits in different ways.</blockquote><blockquote>So technically, branches are not paths but actually nicknames for the latest flag on a path (or any flag, in general). But for beginners, it’s easier to think of branches as paths instead of just commit aliases, so we’ll try to move forward with this analogy as much as possible.</blockquote><h3>Work done on the main line</h3><p>Remember how we work on a personal space so that our work does not clash with others, and then at the end of our work, we merge work done on our personal space into the main line. This means that by the time we get to merge our work into the main line, it’s possible that the main line is updated with someone else’s work — and this happens all the time when collaborating with others.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/824/0*d39R22jp-C9aMB_n" /></figure><p>Since for this guide we don’t really have actual co-authors, we’ll have to simulate “others’ work” ourselves. Let’s switch back to master (the main branch, that is) and create a commit with poem 4 that represents the work of a co-author. Also, assume that you already instructed your co-authors to start adding headings to the poems they write.</p><pre><strong># Switch to the main branch, master</strong><br>git checkout master<br><strong><em># DIY: </em></strong><strong>Add poem 4 with a heading</strong><strong><em><br># THEN, </em></strong><strong>as usual, stage and commit</strong><br>git add .<br>git commit -m &quot;Add poem 4&quot;</pre><p>So now, while you were working on adding headings to the first three poems of the book, one of the co-authors went ahead, added poem 4 (with heading) and merged his work into master. All that&#39;s left now is to merge our work into the main line.</p><h3>Merging one branch into another</h3><p>Let’s assess the commit tree as it is right now. This is what it looks like:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/982/0*FRNYmWo3ckeOmlqW" /></figure><p>We want to merge our work done in the add-headings branch into the main line master, so the commit tree we need after merging should look something like this:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/998/0*J6RTEDPv2lfTrUwv" /></figure><p>You might be wondering how such a situation is resolved in Git. It would’ve been much easier if no one made any changes to master, no? Then all Git would have to do is to copy our work to master, which is very easy (this is called fast-forwarding, since Git &quot;fast-forwards&quot; the main line to your branch).</p><p>Turns out Git does have a very nice way to resolve such situations, called a <strong>three-way merge</strong>. This involves creating a merge commit that adapts your work to the work done on the main line. If your work doesn’t clash with the work done on the main line, Git can do the merge operation all by itself. Pretty neat, right?</p><p>Let us try this. Since there’s something we need to do on this repository later, we’ll create a copy of our project directory as follows:</p><pre><strong><em># Right now, you&#39;re in the poems directory<br># Go to the parent directory</em></strong><br>cd ..<br><strong># Copy the project folder</strong><br>cp -r poems poems-1</pre><p>How does the Git repository data get copied, you ask? Remember that everything about a Git repository is stored in Git’s personal diary for that project — the .git directory. As long as this directory is included in the copy, the Git repository gets copied too. Also, note that Git doesn&#39;t really care about the name of the project folder - it only cares about what&#39;s inside.</p><h3>Three-way merge</h3><p>We’ll try merging our branch into master in the copy that we created, so <strong>go to that directory</strong>.</p><p>As mentioned above, the three-way merge creates a “merge commit” in the target branch (here, master) that represents the work done in the feature branch (here, add-headings). Let&#39;s try it.</p><pre><strong># Switch to the target branch</strong><br>git checkout master<br><strong># Merge the feature branch with message</strong><br>git merge add-headings -m &quot;Add headings to existing poems&quot;</pre><p>Yes, that’s all. Git just added a “merge commit” to master that includes all the work that was done in the branch add-headings. We also specified a message for the merge commit that summarises the work done in the feature branch. Simpler than you thought?</p><h3>Merge conflicts</h3><p>Here’s where things get slightly tougher. I mentioned above that Git can do the merge operation by itself if your work does not clash with work on the target branch, which was the case here. Your work was done on files poem1.txt, poem2.txt and poem3.txt, while work done on master involved a new file poem4.txt being added to the project. Clearly none of the files were involved in work on both branches.</p><p>So what happens when different branches do different work on the same part of a file? That leads to the situation most dreaded by Git beginners — merge conflicts. As the name says, a merge conflict refers to a file conflict that arises while merging one branch into another. And resolving a merge conflict is seen as a tough task, but only until you do it for the first time — after that, it’s smooth sailing. So let’s go for it.</p><p>Go back to the original project directory. Since we want to trigger a merge conflict, we’ll have to change some stuff. Let’s add another commit to master that makes changes in poem 1. Say a co-author did not listen to your instruction and added his own different heading to poem 1 himself, so that the poem now reads:</p><pre>The Bells Jingle</pre><pre>Jingle bells, jingle bells <br>Jingle all the way <br>Oh what fun it is to ride <br>In a one-horse open sleigh!</pre><p>To make the above changes (on behalf of our co-author), we’ll execute:</p><pre><strong># Switch to master</strong><br>git checkout master</pre><pre><strong><em># DIY: </em></strong><strong>Edit poem1.txt as above<br></strong><strong><em># THEN, </em></strong><strong>stage and commit as usual:</strong><br>git commit -am &quot;Add heading in poem 1&quot;<br><strong># (one-liner for &quot;stage all and commit&quot;)</strong></pre><p>So now the commit tree would be something like this:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/982/0*YRqU6BcKm1ZOmKr5" /></figure><p>Fair enough — let’s go for the merge:</p><pre><strong># On branch master,</strong><br>git merge add-headings</pre><p>… and if you did all of the above correctly, you should be face-to-face with your first merge conflict. Although this one is probably much smaller than what you’d face in a real project, resolving it will hopefully go a good way in getting comfortable with Git. Before we start with resolving the conflict, let’s look at the output of the above command:</p><pre>Auto-merging poem1.txt<br><strong>CONFLICT (content):</strong> Merge conflict in poem1.txt<br>Automatic merge failed; fix conflicts and then commit the result.</pre><p>So Git tried to merge the contents of poem1.txt from the target branch and feature branch, but ran into a conflict. So automatic merge failed, on which Git instructs you to fix the conflicts manually and commit the result.</p><p>Okay, let’s look at the contents of poem1.txt:</p><pre><strong>&lt;&lt;&lt;&lt;&lt;&lt;&lt; HEAD</strong><br>The Bells Jingle<strong><br>=======</strong><br>Jingle Bells<br><strong>&gt;&gt;&gt;&gt;&gt;&gt;&gt; add-headings</strong></pre><pre>Jingle bells, jingle bells<br>Jingle all the way<br>Oh what fun it is to ride<br>In a one-horse open sleigh</pre><p>This is Git’s way of showing you what the merge conflicts were. It edits the files to add <strong>conflict blocks</strong>, each of which represents a piece of conflicting contents from the two branches, and allows you to make changes accordingly.</p><p>The lines between &lt;&lt;&lt;&lt;&lt;&lt;&lt; HEAD and ======= show the contents in the target branch (here, master) while the lines between ======= and &gt;&gt;&gt;&gt;&gt;&gt;&gt; add-headings show the contents from the feature branch (here, add-headings). In addition, there may actually be multiple such blocks in a single file, where each block will represent a conflicting section of the file.</p><p>Here’s the golden rule to resolve merge conflicts in a three-way merge: <strong>edit the file, so that its contents represent the final content of the file you want in the main line, after the merge.</strong></p><p>So what do you want the title of this poem to be, after the merge? Let’s go with “Jingle Bells”, because it sounds better. Edit the file so that it finally looks like this:</p><pre>Jingle Bells</pre><pre>Jingle bells, jingle bells<br>Jingle all the way<br>Oh what fun it is to ride<br>In a one-horse open sleigh</pre><p>Once that is done, let’s proceed with the merge:</p><pre><strong># Stage changes in poem1.txt</strong><br>git add .<br><strong># Commit the changes</strong><br>git commit -m &quot;Add headings to existing poems&quot;</pre><p>Boom — you just encountered and resolved your first merge conflict ever! It may seem a bit difficult when doing it the first time, but if you look closely, the concept is quite simple:</p><ol><li>Merge conflicts happen when the same part of a file is changed both in the target branch and the feature branch.</li><li>When this happens, Git does not know which parts to keep so it marks the areas of merge conflict in the corresponding files.</li><li>You open the files, see what the conflict is, think about it and make necessary changes to the file (and optionally other files too) so that the final version is as you want it to be.</li><li>Stage, commit and done!</li></ol><p>Note that it’s not necessary to pick one of the versions from the target or feature branch. In programming projects, you often have to read the code properly to understand the situation, and may have to mix and match stuff from the two versions so that the final code works like you want. In fact, sometimes it may also need changes in other files which don’t even have conflicts. Git’s job is only to show you conflicting blocks — your job is to edit stuff so that finally things are as expected.</p><h3>Summary</h3><p>Okay, so we covered one of the more difficult parts of Git in this part of the guide:</p><ul><li>Branches are used to maintain parallel lines of work, and are widely used in projects with a lot of use cases, including collaboration and project management.</li><li>While collaborating, the general workflow is to keep your work in branches separate from the main line (generally the master branch), and merge your work branch into the main line once done.</li><li>If work in the target branch and the feature branch do not clash, Git can automatically merge the branches without the user’s help.</li><li>If work does clash, Git marks the sections of conflict in the files themselves. Then the user can fix these sections accordingly and commit the changes.</li></ul><p>In the next part, we’ll cover the topic that will probably be the most useful to you in daily life — using GitHub, and dealing with remote repositories in general. We’ll also learn rebasing, a cleaner alternative to three-way merge.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=ae27f6b72f3b" width="1" height="1" alt=""><hr><p><a href="https://medium.com/programming-club-iit-kanpur/a-guide-to-git-branches-and-merging-ae27f6b72f3b">A Guide to Git: Branches and Merging</a> was originally published in <a href="https://medium.com/programming-club-iit-kanpur">Programming Club, IIT Kanpur</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[A Guide to Git: The Fundamentals]]></title>
            <link>https://medium.com/programming-club-iit-kanpur/a-guide-to-git-the-fundamentals-2d3db6b4df53?source=rss-ad9289b653f0------2</link>
            <guid isPermaLink="false">https://medium.com/p/2d3db6b4df53</guid>
            <category><![CDATA[version-control]]></category>
            <category><![CDATA[programming]]></category>
            <category><![CDATA[git]]></category>
            <category><![CDATA[beginners-guide]]></category>
            <category><![CDATA[github]]></category>
            <dc:creator><![CDATA[Nilay Majorwar]]></dc:creator>
            <pubDate>Fri, 15 Jan 2021 10:26:59 GMT</pubDate>
            <atom:updated>2021-05-14T07:40:44.809Z</atom:updated>
            <content:encoded><![CDATA[<p>Over the past year, I’ve seen a lot of students having trouble with using Git effectively. For a lot of people, using Git simply means knowing a certain set of commands that you do when you want to commit, a certain set for pushing or pulling. And if there’s a merge conflict, run to someone who’s done it before for help.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/661/0*6nwrYCGTdsk_5C7y" /><figcaption>xkcd #1597: The state of most beginner programmers who “know” how to use Git.</figcaption></figure><p>And honestly, I think it’s a phase in every programmer’s curve — myself included. It took around a year of programming (and using Git) to actually understand what Git is, and to be able to resolve most Git-related issues easily.</p><p>This three-part guide is an attempt to teach (or re-teach) Git in a better way, so that you understand what happens backstage with each Git command you execute, and not become someone who only knows how to use Git.</p><p>And it’s really, really, much easier than you think.</p><h3>So what is Git, then?</h3><p>Git is a version control system. It helps the user in maintaining various versions of a project. It’s not the only one, by the way — there are alternatives like Mercurial and SVN, but Git rocks so much more that nearly no one uses anything else. Maybe because it’s made by the same guy who created Linux.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/733/0*R89x2rvFZQ5y3phM" /><figcaption>The classic “solution” to managing versions</figcaption></figure><p>So if you’ve ever done the above, Git is a much easier, cleaner and maybe even safer way to do what you want to. Really, that is pretty much all Git does at the core — it <strong>maintains versions</strong> of something.</p><p>If you like analogies, Git is a butler standing by your work table. Imagine you start writing a new novel and tell the butler to keep track of your work. Now whenever you make any significant changes to your novel (say you just renamed Emma to Clara), you show the butler your changes saying “hey, I just renamed Emma to Clara” and the butler will remember it. Now a month later you can say “hey butler, you still remember how things were when I renamed Emma to Clara” and the butler can read out the whole novel like it was after the renaming. That’s what Git does — it’s simply a <strong>bookkeeping butler</strong>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/500/1*wzO5d4QLKxaj0zXYDWwqjw.png" /></figure><p>Before we start with the series, let me clear something out: you might have heard of GitHub, but remember that Git and GitHub are way different. GitHub is an <em>online</em> platform that uses Git for version management and gives you access to some Git operations through the GUI, rather than using commands. This does not mean GitHub is a GUI for Git — these have their own different uses, as will be apparent in later parts.</p><h3>Pre-Requisites</h3><p>This guide does not assume any prior knowledge or experience with Git or any other version control system, but knowledge of basic commands like cd and mkdir will really help in understanding and following the guide.</p><h3>Setting Git up</h3><p>This is platform-dependent, so I won’t cover the process here. The <a href="https://github.com/git-guides/install-git">GitHub guide to installing Git</a> is pretty good, so follow that to install Git on your system.</p><blockquote><strong>For Windows users:</strong> If the Git installer offers to install Git Bash, go for it. It offers a similar command-line environment to what I’ll use in this article.</blockquote><p>To ensure that Git is properly installed, the command git version should output the version of Git you&#39;ve installed. If it outputs something that&#39;s not &quot;command not found&quot;, you&#39;re probably fine.</p><p>Then, you must add your basic information to your Git installation — this is necessary to use Git. To do this, execute the following commands, replacing the name and email ID with yours:</p><pre>git config --global user.name &quot;John Doe&quot;<br>git config --global user.email &quot;johndoe@example.com&quot;</pre><p>If that works correctly, you’re good to go.</p><h3>Some basic terminology</h3><p>Before we start playing around with Git, let’s get our heads around a couple of terms that are extremely important to understand what Git does behind the scenes. It might not make sense right now, but everything will hopefully fit in by the end of the article.</p><h4>Repository</h4><p>A repository represents a piece of work that you want Git to maintain for you. On a computer, this “piece of work” refers to a single directory — so if you’re writing a novel and you want to use Git, you’d create a folder for the novel, keep your work inside that folder and tell Git to keep track of this folder.</p><h4>Commit</h4><p>A commit is the unit of change in Git. So when you “commit” your changes to Git, you’re basically saying “here Git, I made these changes to the piece of work, have a look” and Git remembers it. Showing the butler your changes when you renamed Emma to Clara is simply making a commit of your work.</p><h3>Starting the book</h3><p>Okay, so with everything finally set up, let’s start writing a book of nursery rhymes, because why not — it’s low effort and has never-ending demand.</p><p>We will be writing our book in multiple text files, with one file for each nursery rhyme. So let’s first create a directory for our novel, I’ll call it “poems”.</p><pre>mkdir poems<br>cd poems</pre><p>So we made a directory for our new book. Let’s now initialise the Git repository for this directory.</p><pre>git init</pre><p>Yeah, as simple as that. git init tells Butler Git that everything in the current directory is a piece of work that Git needs to maintain. Notice that executing this command creates a hidden directory .git in the current directory. This is the butler&#39;s personal diary - whatever updates you give to Git about your work, Git keeps it here.</p><p>Before we start with our repository, a few points to take care of:</p><ul><li>To execute Git commands for a repository, you have to be inside that project directory. Every repository has its own .git directory that stores data about that repository.</li><li>In all code blocks used in this guide, lines starting with a # (hashtag) are Bash comments and are used to describe what the command does. You don’t need to execute these on the terminal.</li></ul><h3>The First Poems</h3><p>Right now, Butler Git only knows you’ve started writing a book. So let’s write the first rhyme. Create a file named poem1.txt and write the first rhyme there. Here&#39;s what I have for the first one:</p><pre>Jingle bells, jingle bells<br>Jingle all the way<br>Oh what fun, it is to ride<br>In a one-horse open sleigh!</pre><p>(yes, not very impressive, I know)</p><p>So now that we’ve written the first poem, we should tell Butler Git about our progress. Or in Git terminology, we need to <strong>commit</strong> our changes. But before that, let’s try a commonly used command: git status. The output should be something as follows:</p><pre><strong>On branch master</strong></pre><pre>No commits yet</pre><pre><strong>Untracked files:</strong><br>  <em>(use &quot;git add &lt;file&gt;...&quot; to include in what will be committed)</em><br>	poem1.txt</pre><pre>nothing added to commit but untracked files present (use &quot;git add&quot; to track)</pre><p>This is a staple command of Git that shows the current status of the repository. Most importantly, it shows the changes you’ve made since the previous commit, including modified files, untracked files (i.e new files) and deleted files. poem1.txt is a new file, so it&#39;s listed under &quot;Untracked files&quot;.</p><p>Now, committing changes to Git is a bit of a multistage process. It’s a combination of two steps:</p><ol><li><strong>“Staging” your changes:</strong> Here, we select what changes we want to actually commit to the repository. If you’ve made multiple changes, you can choose here what changes you want to inform the butler about. It’s like sending some (or usually all) of your changes to the stage for Butler Git to see.</li><li><strong>Committing your staged changes:</strong> Once we know what changes we need to commit, we write a brief message that describes the changes we’re committing, and then make a commit with this message.</li></ol><p>So let’s do it.</p><p>You stage your changes by <strong>add</strong>ing your changes to the stage. If you’re in the poems directory, execute the following command to add changes in the poem1.txt file to the stage.</p><pre><strong># Stage changes in poem1.txt</strong><br>git add poem1.txt</pre><p>Try git status again, and it should show poem1.txt as a staged change. Let&#39;s commit this staged change now. Since the change we&#39;re going to commit represents the addition of the first poem, &quot;Add poem 1&quot; is a pretty good commit message.</p><pre><strong># Commit (staged) changes to repository</strong><br>git commit -m &quot;Add poem 1&quot;</pre><p>There we go, you just did your first Git commit! Remember, a commit takes all of your <strong>staged</strong> changes and submits it to the repository. So stage only those changes that you want to commit to the repository.</p><p>Let’s add another poem:</p><pre>Twinkle twinkle, little stars <br>How I wonder, what you are <br>Up above the world so high <br>Like a diamond in the sky.</pre><p>Follow the same process as above: stage and commit. “Add poem 2” is a good commit message.</p><h3>Viewing history and checkout past versions</h3><p>Let’s add another poem and commit the changes. As usual, we’ll keep the commit message as “Add poem 3”.</p><pre>Baa baa black sheep, have you any wool? <br>Yes sir, yes sir, three bags full. <br>One for the master, one for the dame, <br>And one for the little boy who lives down the lane.</pre><p>Now with a Git-managed project, the butler knows the full history of how the project was done — let’s try it out. Execute the command git log. You should get an output similar to the following:</p><pre><strong>commit db57112cadfe51f65d026d9f51aecb792a7fef43 (HEAD -&gt; master)</strong><br>Author: John Doe <em>&lt;johndoe@gmail.com&gt;</em><br>Date:   Thu Dec 31 20:57:27 2020 +0530</pre><pre>    Add poem 3</pre><pre><strong>commit f8dad3229118769a6b57eef76462845cadcd9efd</strong><br>Author: John Doe <em>&lt;johndoe@gmail.com&gt;</em><br>Date:   Thu Dec 31 20:56:44 2020 +0530</pre><pre>    Add poem 2</pre><pre><strong>commit 2df75a984cf42aa02cb28ec4344d1c155e43f718</strong><br>Author: John Doe <em>&lt;johndoe@gmail.com&gt;</em><br>Date:   Thu Dec 31 20:55:49 2020 +0530</pre><pre>    Add poem 1</pre><p>git log shows you the history of commits made in the current repository, with latest commits at the top. Note that each commit is associated with:</p><ul><li><strong>Commit hash</strong>: the long hex string in each commit. It’s unique for each commit.</li><li><strong>Author</strong>: the person who made the commit — in this case, you.</li><li><strong>Timestamp</strong>: the date and time at which the commit was made</li></ul><p>Ignore the (HEAD → master) part for now - we&#39;ll come back to it later.</p><p>I know, recording project history isn’t really a killer feature. But going back in history is, so let’s try doing that. Let’s go one commit back in the project — or in Git terms, let’s <strong>checkout</strong> the project a commit back.</p><pre><strong># Checkout a project one commit back</strong><br>git checkout HEAD~1</pre><pre><strong># The output may look a bit scary but don&#39;t worry, you&#39;re fine.</strong></pre><p>Once you’ve done that, have a look at the contents of your project folder. Voila, Git just tracked back your actual project files one commit back! Don’t worry, our work on poem3.txt isn&#39;t lost - they&#39;re there in Butler Git&#39;s personal diary.</p><p>What does the HEAD~1 in the checkout command mean though? The term HEAD represents the commit the project currently is at. Since before executing the command our project was at commit &quot;Add poem 3&quot;, HEAD would have represented that commit. Then, the ~1 part says &quot;one commit before&quot;, so HEAD~1 means &quot;one commit behind the current commit&quot;, or in simpler terms, &quot;one commit back&quot; which is what we wanted.</p><blockquote>In case you messed up something in the checkout, execute git checkout master to return to the latest commit (&quot;Add poem 3&quot;).</blockquote><p>You can also checkout directly to a commit, by using the first 7 characters of the commit hash as the commit identifier. So the above checkout can also be done using:</p><pre><strong># Checkout a commit directly</strong><br>git checkout f8dad32</pre><h3>An Inside View</h3><p>All of our discussions and practicals have only given us a view from the audience seat. To understand Git properly, it’s essential to have a good idea of what goes on behind the scenes when we execute Git commands. We’ll represent our directory along with the Git repository (as it was before, adding poem 3) as follows:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1000/0*gw0CXkbMyWod6vVj" /></figure><p>The red pane represents your file system — the actual files you would see in your project directory. The green pane is the staging area — it’s a place inside Git where your staged changes are kept track of. The blue pane shows the butler’s personal diary — it records the current commit you are at, and what that commit contains.</p><p>Now let’s add the contents of Poem 3 in a new file. The file system pane would get updated with the new file. Note that since we haven’t staged any changes yet, the staging area would still be empty.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1000/0*kQCEEs7p_yl7i5EM" /></figure><p>Now, when we staged our changes with git add poem3.txt, Git adds a change to the staging area - that we <strong>add</strong>ed a new file called poem3.txt. The staging area would then look like this:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1000/0*bu3poHwUfuqs1uFs" /></figure><p>Next, we commit our changes to the repository with git commit -m &quot;Add poem 3&quot;. This submits our staged changes (just one, in this case) to the repository in the form of a new commit. So, our staging area gets cleared and the repository gets updated with the new commit:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1000/0*OwpUmwd8Hu1ogeeX" /></figure><p>Finally, let’s try checking out the project one commit back, with git checkout HEAD~1. This asks the repository to track back to one commit earlier, and make changes to our file system so that it matches with the older state of the project:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*dIMb-wiy0NZEMTCEemlMQA.png" /></figure><p>There, now you know what happens the scene when someone stages changes, makes a commit or checks out past commits. It’s really as simple as that.</p><h3>Summary</h3><p>We covered a lot of the fundamentals of Git. In particular, we covered the following commands:</p><ul><li>git init: Initialises a Git repository in the current directory</li><li>git status: Displays the current status of the repository</li><li>git add: Stage the changes of a single file or directory</li><li>git commit: Commit all staged changes to the repository</li><li>git checkout: Check out a past version of the project</li></ul><p>… and had a good look at the backstage when these commands are executed.</p><p>But this is just the tip of the iceberg — Git has a very cool commit tree structure underneath that allows for some useful concepts and features like branching and merging. That’s something we’ll cover in the <a href="https://medium.com/programming-club-iit-kanpur/a-guide-to-git-branches-and-merging-ae27f6b72f3b">next part of the series</a>.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=2d3db6b4df53" width="1" height="1" alt=""><hr><p><a href="https://medium.com/programming-club-iit-kanpur/a-guide-to-git-the-fundamentals-2d3db6b4df53">A Guide to Git: The Fundamentals</a> was originally published in <a href="https://medium.com/programming-club-iit-kanpur">Programming Club, IIT Kanpur</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
    </channel>
</rss>