<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Ankith Deegoju</title>
    <description>The latest articles on DEV Community by Ankith Deegoju (@ankith_deegoju_155982c916).</description>
    <link>https://dev.to/ankith_deegoju_155982c916</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F1778213%2F5003112a-5d77-4bb9-91a3-cd038a7bd1a6.png</url>
      <title>DEV Community: Ankith Deegoju</title>
      <link>https://dev.to/ankith_deegoju_155982c916</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/ankith_deegoju_155982c916"/>
    <language>en</language>
    <item>
      <title>Basics of Git - Part 2</title>
      <dc:creator>Ankith Deegoju</dc:creator>
      <pubDate>Fri, 15 May 2026 06:56:11 +0000</pubDate>
      <link>https://dev.to/ankith_deegoju_155982c916/basics-of-git-part-2-25n6</link>
      <guid>https://dev.to/ankith_deegoju_155982c916/basics-of-git-part-2-25n6</guid>
      <description>&lt;p&gt;In this blog we will explore the concept of -&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Branches&lt;/li&gt;
&lt;li&gt;Push, pull, merge&lt;/li&gt;
&lt;li&gt;Pull Request and how can we contribute to any repo.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;To understand above concepts we will follow a hands on approach of doing things - &lt;/p&gt;

&lt;p&gt;&lt;em&gt;Repo - Repository - Folder tracked by Git.&lt;/em&gt;&lt;/p&gt;

&lt;h4&gt;
  
  
  Methods to access an existing repo -
&lt;/h4&gt;

&lt;ul&gt;
&lt;li&gt;Directly download the repo from GitHub and open it in our terminal&lt;/li&gt;
&lt;li&gt;We can fork the repo using fork button on github - This creates your own copy of the repo.&lt;/li&gt;
&lt;li&gt;We can use git clone command to clone the repo locally.
Command - git clone “Add repo-link  here”&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;We will understand the concepts of cloning,  remote conenction establishment, branching through the below steps.&lt;/p&gt;

&lt;p&gt;Let’s create a new repo in GitHub. I have created a test_repo.&lt;/p&gt;

&lt;p&gt;We get something like this  -&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fwmdv6gbsowz3f83x25ta.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fwmdv6gbsowz3f83x25ta.png" alt=" " width="800" height="264"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Copy the link here.&lt;/p&gt;

&lt;p&gt;Use the git clone command to clone the repo locally - &lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F06m5h1zinb3nl5n0sen1.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F06m5h1zinb3nl5n0sen1.png" alt=" " width="800" height="78"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Let’s add a few files into it and we will also use some of the commands from our previous blog to add the files into staging, commit the changes, then push the code into GitHub.&lt;/p&gt;

&lt;p&gt;I have created two files in the repo. [ You can refer prev blog / google it to create files in a repo ]&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fd34d8dlk288d4dteqmcu.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fd34d8dlk288d4dteqmcu.png" alt=" " width="707" height="191"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;To push the code to GitHub we need to establish a remote connection with the GitHub repo. By default a remote connection with name origin is created if we use git clone command.&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Why do we want to push code - Everyone with the repo link can view the updates in the code.&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;Command to establish remote connection - git remote add “remote-connection-name” “repo-link” &lt;/p&gt;

&lt;p&gt;To view all existing remote connections in that repo .&lt;br&gt;
Command - git remote -v&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F0vwdmt93jvokyh60noej.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F0vwdmt93jvokyh60noej.png" alt=" " width="800" height="187"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;We can remove connection using command - git remote remove “remote-connection-name” .&lt;/p&gt;

&lt;p&gt;Suppose we want to develop a project and we have a team of developers.  We create a repo on GitHub. We then add a remote connection to that repo via our terminal, to make changes in our local system independently and then push those changes to the repo. &lt;/p&gt;

&lt;p&gt;Why do we create a remote connection - To make changes locally in our system verify them once if they are properly working from our side and then pushing those to the github for the team to look into and review before deploying it. &lt;/p&gt;

&lt;p&gt;I have also forked a public repo for example and did few things in the code.&lt;br&gt;
Ex- git remote add origin &lt;a href="https://github.com/NirDiamant/RAG_Techniques.git" rel="noopener noreferrer"&gt;https://github.com/NirDiamant/RAG_Techniques.git&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;To view all existing remote connections  - git remote -v&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fqcbnpd3my7iohk6c51x8.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fqcbnpd3my7iohk6c51x8.png" alt=" " width="800" height="134"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Generally what happens is the repo’s MAIN / MASTER branch is generally connected to the hosting platform where our application in deployed [This is not always true]. Any changes to the MASTER branch will be reflecting in our production directly. To avoid any unnecessary issues , the MASTER branch of the repo is locked so that none of the developers can directly push the code to the production without proper check . So each developer creates a separate branch of the same repo, makes his/her changes then  raises a pull request [PR], the manager / testing team after verification of the changes pushes the code into MASTER branch.&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;By default after cloning a repo, a MASTER branch is created in the local repo, which will be connected to the MASTER branch of the repo. &lt;/p&gt;

&lt;p&gt;In my local experiments the default branch name is MASTER. Modern GitHub repositories use main by default not MASTER.&lt;/p&gt;

&lt;p&gt;We need to use remote connection name and branch name to push changes into GitHub / MASTER branch.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fjt1qeb02j064z9frdnvd.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fjt1qeb02j064z9frdnvd.png" alt=" " width="800" height="660"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;What is a branch - Independent line of development&lt;/p&gt;

&lt;p&gt;How do we create branches - Using command &lt;br&gt;
git branch  &lt;/p&gt;

&lt;p&gt;To view all existing branches - git branch -a&lt;br&gt;
Naming convention followed while creating branches- Developer Name/Feature Name&lt;/p&gt;

&lt;p&gt;Fetch - Used to download the latest updates from GitHub repository and updates the remote tracking branch like remotes/origin/MASTER, without modifying our local working branch.&lt;/p&gt;

&lt;p&gt;Use command - git fetch origin [ This fetches all branches from origin]&lt;/p&gt;

&lt;p&gt;git fetch origin "branch-name" [ The changes are fetched from the specified branch name ]&lt;/p&gt;

&lt;p&gt;We will manually add few changes in our repo from GitHub to understand fetch command in the GitHub repo. I have added changes in the two base files created via GitHub web app.&lt;/p&gt;

&lt;p&gt;To compare changes from your local repo MASTER branch to the github repo’s MASTER branch we use - git diff MASTER origin/MASTER&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fra9j5ml3ew2934crnb64.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fra9j5ml3ew2934crnb64.png" alt=" " width="800" height="590"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;So we have made changes directly in the MASTER branch of repo in the GitHub.&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Using fetch command we can compare our repo code with latest github repo code and if needed the new changes can be copied into our local repo to maintain sync with the  changes in the repo.&lt;/em&gt;  &lt;/p&gt;

&lt;p&gt;Branching - Switch command&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fcq2oz1298hztk4t83isr.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fcq2oz1298hztk4t83isr.png" alt=" " width="800" height="162"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;We can update our repo with the newly made changes using git pull command. But we need to set upstream for a branch to enable push and pull changes. This upstream links a local branch to a remote branch. &lt;/p&gt;

&lt;p&gt;Command - git branch —set-upstream-to=origin/MASTER&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fuu8m86rtifaa4uairkfb.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fuu8m86rtifaa4uairkfb.png" alt=" " width="800" height="79"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Now we can pull changes using pull command - &lt;/p&gt;

&lt;p&gt;git pull origin [If upstream is already set- fetch and merge latest changes into the current local branch from the connected remote branch] &lt;/p&gt;

&lt;p&gt;git pull origin "branch-name" [ The changes are pulled into the specifed branch name ]&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fvhopoil9vcdiju79et3k.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fvhopoil9vcdiju79et3k.png" alt=" " width="695" height="167"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;To observe all the commit history of the branch - We can do it using command git log —oneline. &lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F24nr026w5inbng7mgfsu.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F24nr026w5inbng7mgfsu.png" alt=" " width="800" height="126"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The branch Ankith/Feat1 is at commit 7864cda i.e. behind the MASTER branch of the local repo by two commits. So now we can merge these changes in  Ankith/feat1 branch from the MASTER branch of local repo to keep all the branches in sync. &lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F7xbtj13ee8rxzngq82tj.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F7xbtj13ee8rxzngq82tj.png" alt=" " width="713" height="160"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Explore checkout and restore commands in git.&lt;/p&gt;

&lt;p&gt;Let’s understand merge -— squash . Suppose we make multiple commits in Ankith/feat1 branch . &lt;/p&gt;

&lt;p&gt;Head pointer in the git always points the currently executed / checked-out commit. &lt;/p&gt;

&lt;p&gt;Here we did few commits in the specific branch - Ankith/Feat1&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fgb5fxpfiqnoddx0m1r5g.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fgb5fxpfiqnoddx0m1r5g.png" alt=" " width="800" height="185"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;When we use merge command all the three commits are merged into MASTER . &lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fomc4c2xpekrqheiybkfs.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fomc4c2xpekrqheiybkfs.png" alt=" " width="800" height="390"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Instead we can also merge all the commits of Ankith/feat1 into MASTER branch using single commit by squashing all the commits into a single commit.&lt;/p&gt;

&lt;p&gt;As we merge the changes from Ankith/feat1 branch to MASTER branch, the changes are placed into staging area.  On commit operation these changes are made to MASTER branch with a single commit.&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Generally we delete the branch once the changes are pushed to MASTER branch.&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fnj7ap334ou50fhwf2tx4.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fnj7ap334ou50fhwf2tx4.png" alt=" " width="800" height="449"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Pushing - To push changes made in  the local MASTER branch into Github &lt;br&gt;
Command - git push origin.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F7edbw6hxa8ukdcsplx1o.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F7edbw6hxa8ukdcsplx1o.png" alt=" " width="785" height="197"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Rebase -  Suppose we  have two branches Ankith/Feat2, MASTER. Suppose my friend has added many features into the MASTER branch. In this case of many changes in a MASTER branch  i.e. all the structure  of your Ankith/Feat2 branch  is different from initial setup then we can use rebase to place your branch commits on top of latest MASTER branch, creating cleaner linear history.&lt;/p&gt;

&lt;p&gt;Here we can resolve merge conflicts either automatically or manually.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fi85oi7fn54zqshzmrfn0.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fi85oi7fn54zqshzmrfn0.png" alt=" " width="800" height="502"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;We can explore the above topics in a bit depth by using these commands and playing with them.&lt;/p&gt;

&lt;p&gt;Explore about how Pull Request is created in an org and in open source contributions, if possible add pull request to my repo  - &lt;a href="https://github.com/ANKITHDEEGOJU/Test_Repo" rel="noopener noreferrer"&gt;https://github.com/ANKITHDEEGOJU/Test_Repo&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;If possible do create your open repo and configure it to allow PR”s from others by modifying the branch settings. [ Explore Protected Branches]&lt;/p&gt;

&lt;p&gt;&lt;em&gt;A small clarity - if you are the owner of the repo then you have the permission to directly push changes to MASTER branch, else you can push code directly to your custom branch and then raise a PR [if admin of the repo provides you access to create your own branch]. Generally people fork the repo , create their individual branch in the local repo , then push code to the MASTER branch of this local repo, check if everything is fine. Then send PR to admin/ maintainer to accept the updates. Then the  maintainer verifies the code changes then accepts the pull request , merges changes into the main/MASTER branch of the repo.&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;Reference - &lt;a href="https://git-scm.com/cheat-sheet" rel="noopener noreferrer"&gt;Git Cheat Sheet&lt;/a&gt;&lt;/p&gt;

</description>
      <category>webdev</category>
      <category>programming</category>
      <category>beginners</category>
      <category>tutorial</category>
    </item>
    <item>
      <title>Basics of Git -</title>
      <dc:creator>Ankith Deegoju</dc:creator>
      <pubDate>Fri, 20 Mar 2026 11:37:06 +0000</pubDate>
      <link>https://dev.to/ankith_deegoju_155982c916/basics-of-git--4af6</link>
      <guid>https://dev.to/ankith_deegoju_155982c916/basics-of-git--4af6</guid>
      <description>&lt;h2&gt;
  
  
  What is Git.
&lt;/h2&gt;

&lt;p&gt;Git is a version control system. Version Control System is a software that manages changes of your code/files in a folder/directory. &lt;/p&gt;

&lt;h3&gt;
  
  
  What is the problem its solving -
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;Provides us tracking of changes in codebase.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Provides us simultaneous access to codebase enabling collaboration&lt;br&gt;
[ via GitHub -&amp;gt; Simply say git in a server || Even I need to deep dive into it ]&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Provides us a single source of truth i.e. provides us exact state of code base that is constantly being updated with changes done by members accessing the code base.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;To understand it's importance and need of git.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Scenario&lt;/strong&gt; - &lt;em&gt;Imagine how you would collaborate with other developers and build together a project.&lt;/em&gt; &lt;/p&gt;

&lt;p&gt;Suppose you have multiple people working with the same codebase but need simultaneous access and push changes independent of others in different parts of codebase. &lt;/p&gt;

&lt;p&gt;Era before git - By sharing code via pendrive.&lt;br&gt;
Think of use cases like - How can we provide simultaneous access and consistent updates of code across all developers of the code base.&lt;/p&gt;

&lt;p&gt;I would like to explore other ideas which you can think of in the above context.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;How was git built&lt;/strong&gt; - [Just a short story]&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Linus Torvald&lt;/em&gt; was working on Linux. As it was open source project many developers pushed code to improvise it, eventually the code base was too big to track and update changes. To solve this issue git was developed as his side project.&lt;/p&gt;


&lt;h2&gt;
  
  
  How do we use git -
&lt;/h2&gt;

&lt;p&gt;[Start doing it in a system with me]&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;&lt;p&gt;Create a folder - LearningGit &lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Create two files - ex - demo1.txt , demo2.txt&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Open your terminal and let's work in it now on.&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Few basic commands -&lt;/p&gt;

&lt;p&gt;ls - to list files in a folder.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;              Linux/WSL         Command Prompt (cmd)
List Files   ls               dir

Detailed List   ls -l             dir

Show Hidden ls -a            dir /a

All Details ls -la               dir /a
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;nano - Linux -&amp;gt; To create and edit files&lt;/p&gt;

&lt;p&gt;edit - Windows -&amp;gt; Installation Command - winget install Microsoft.Edit&lt;/p&gt;

&lt;p&gt;Usage:- &lt;code&gt;&amp;gt; edit &amp;lt;filename&amp;gt;&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;Key Bindings { Shortcut Keys } -&amp;gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Ctrl+S to save.

Ctrl+F for find and replace.

Ctrl+Q to exit. 

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

&lt;/div&gt;



&lt;p&gt;Add some info into your files .&lt;/p&gt;

&lt;p&gt;cat - Linux -&amp;gt; To view file data&lt;/p&gt;

&lt;p&gt;type - Windows &lt;/p&gt;

&lt;p&gt;Usage - &lt;code&gt;type file.txt&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;Concatenate/Merge files: type file1.txt file2.txt &amp;gt; combined.txt&lt;/p&gt;

&lt;p&gt;Let's now start using our git commands .&lt;/p&gt;

&lt;p&gt;&lt;code&gt;git init&lt;/code&gt; - Initializes git inside your folder with by creating a .git file.&lt;/p&gt;

&lt;p&gt;O/P =&amp;gt; Initialized empty Git repository in C:/WebDev/LearningGit/.git/&lt;/p&gt;

&lt;p&gt;&lt;code&gt;git status&lt;/code&gt;- TO check the status &lt;/p&gt;

&lt;p&gt;Red - Untracked&lt;br&gt;
Green - Files that are being tracked / staged to be tracked.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Staging&lt;/strong&gt; -&lt;/p&gt;

&lt;p&gt;We need to stage files that we wish to track. A way to tell git to look into these files.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;git add &amp;lt;filename&amp;gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; For individual file to be tracked

git add &lt;span class="nb"&gt;.&lt;/span&gt; -&amp;gt; For all files within the directory to be tracked.
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Committing&lt;/strong&gt; - &lt;br&gt;
Once we are okay with changes we can commit the changes so that that we can store them as checkpoints for reference of changes or revert back incase of any fallback. &lt;/p&gt;

&lt;p&gt;Command-&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;git commit &lt;span class="nt"&gt;-m&lt;/span&gt; &lt;span class="s2"&gt;"Initial files"&lt;/span&gt; 
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Try to change the code a few times and try to commit.&lt;/p&gt;

&lt;p&gt;Once committed -&amp;gt; changes are permanently stored in .git file.&lt;/p&gt;

&lt;p&gt;How does it do it.&lt;br&gt;
Under the hood we create a linked list of commits to file. Each new node stores a hash of prev node as a reference. As we have a head pointer in linked list we have a head here which points to the most updated node. &lt;/p&gt;

&lt;p&gt;We can perform git add and commit both in a single command. &lt;br&gt;
&lt;code&gt;git commit -am "msg"&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;&lt;code&gt;git log&lt;/code&gt; - gives us history of commits performed.&lt;/p&gt;

&lt;p&gt;You get the list of commits with a unique hash value associated with each commit. &lt;/p&gt;

&lt;p&gt;We can compare changes form one commit to another using commands- &lt;/p&gt;

&lt;p&gt;&lt;code&gt;git diff &amp;lt;hashval of commit&amp;gt; &amp;lt;hashval of commit to be compared with&amp;gt;&lt;br&gt;
&lt;/code&gt;&lt;br&gt;
&lt;code&gt;git revert hash_id&lt;/code&gt;=&amp;gt; Creates a complement of the given hash_id and attaches head to it.&lt;/p&gt;

&lt;p&gt;The attached screenshot would be helpful.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F5t7qdp8ylaipfx7o8f94.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F5t7qdp8ylaipfx7o8f94.png" alt="Under the hood working of git and basic commands" width="686" height="814"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;We will explore .git folder,git branching, GitHub concepts in the upcoming blogs.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://git-scm.com/cheat-sheet" rel="noopener noreferrer"&gt;Git Cheat Sheet &lt;/a&gt;&lt;/p&gt;

</description>
      <category>programming</category>
      <category>beginners</category>
      <category>tutorial</category>
      <category>learning</category>
    </item>
  </channel>
</rss>
