<?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>Forem: Ankith Deegoju</title>
    <description>The latest articles on Forem by Ankith Deegoju (@ankith_deegoju_155982c916).</description>
    <link>https://forem.com/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>Forem: Ankith Deegoju</title>
      <link>https://forem.com/ankith_deegoju_155982c916</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://forem.com/feed/ankith_deegoju_155982c916"/>
    <language>en</language>
    <item>
      <title>Basics of Git -</title>
      <dc:creator>Ankith Deegoju</dc:creator>
      <pubDate>Fri, 20 Mar 2026 11:37:06 +0000</pubDate>
      <link>https://forem.com/ankith_deegoju_155982c916/basics-of-git--4af6</link>
      <guid>https://forem.com/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>
