<?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 Marouane LAHIA on Medium]]></title>
        <description><![CDATA[Stories by Marouane LAHIA on Medium]]></description>
        <link>https://medium.com/@marouaneinfor?source=rss-93019365ea42------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/0*qRH2h_qCH1qYH6xY.</url>
            <title>Stories by Marouane LAHIA on Medium</title>
            <link>https://medium.com/@marouaneinfor?source=rss-93019365ea42------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sat, 21 Nov 2026 05:40:46 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@marouaneinfor/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[So, what is Git in a nutshell?]]></title>
            <link>https://medium.com/@marouaneinfor/so-what-is-git-in-a-nutshell-fe9f26cf4e87?source=rss-93019365ea42------2</link>
            <guid isPermaLink="false">https://medium.com/p/fe9f26cf4e87</guid>
            <category><![CDATA[git]]></category>
            <category><![CDATA[programming]]></category>
            <category><![CDATA[software-development]]></category>
            <category><![CDATA[technology]]></category>
            <category><![CDATA[version-control]]></category>
            <dc:creator><![CDATA[Marouane LAHIA]]></dc:creator>
            <pubDate>Wed, 13 Dec 2017 16:32:11 GMT</pubDate>
            <atom:updated>2017-12-13T16:32:11.955Z</atom:updated>
            <content:encoded><![CDATA[<p>Git is the most commonly used version control system today and is quickly becoming the standard for version control.</p><p>Git is a distributed version control system, meaning your local copy of code is a complete version control repository. These fully-functional local repositories make it is easy to work offline or remotely.</p><p>You commit your work locally, and then sync your copy of the repository with the copy on the server. This paradigm differs from centralized version control where clients must synchronize code with a server before creating new versions of code.</p><p>Git’s flexibility and popularity make it a great choice for any team. Many developers and college graduates already know how to use Git. Git’s user community has created many resources to train developers and Git’s popularity make it easy to get help when you need it. Nearly every development environment has Git support and Git command line tools run on every major operating system.</p><h3>Git basics</h3><p>This is an important section to absorb, because if you understand what Git is and the fundamentals of how it works, then using Git effectively will probably be much easier for you.</p><p><strong><em>Snapshots, Not Differences</em></strong></p><p>Every time you save your work, Git creates a commit. A commit is a snapshot of all your files at a point in time. If a file has not changed from one commit to the next, Git uses the previously stored file. This design differs from other systems which store an initial version of a file and keep a record of deltas over time.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/500/1*LZFAIcCsJZYzoObk_DIqWw.png" /></figure><p><strong><em>Git Has Integrity</em></strong></p><p>Everything in Git is check-summed before it is stored and is then referred to by that checksum. This means it’s impossible to change the contents of any file or directory without Git knowing about it.</p><p>This functionality is built into Git at the lowest levels and is integral to its philosophy. You can’t lose information in transit or get file corruption without Git being able to detect it.</p><p>The mechanism that Git uses for this checksumming is called a SHA-1 hash. This is a 40-character string composed of hexadecimal characters (0–9 and a– f) and calculated based on the contents of a file or directory structure in Git. A SHA-1 hash looks something like this:</p><blockquote>b8ae79fa5d66684d69d0a41ca11d999f4c0d5339</blockquote><p>You will see these hash values all over the place in Git because it uses them so much. In fact, Git stores everything not by file name but in the Git database addressable by the hash value of its contents.</p><p><strong><em>Files and commits</em></strong></p><p>Files in Git are in one of three states: <em>modified, staged, or committed</em>. When you first modify a file, the changes exist only in your working directory. They are not yet part of a commit or your development history. You must stage the changed files you want to include in your commit (you can omit files that you wish to commit separately).</p><p>The staging area contains all changes that you will include in your next commit. Once you’re happy with the staged files, commit them with a message describing what changed. This commit becomes a part of your development history.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/296/1*y6XHMxv_CX6l4TCUmgOLSQ.png" /></figure><p>Staging lets you pick which file changes to save in a commit so you can break down large changes into a series of smaller commits. When you reduce the scope of your commits, it’s easier to review the commit history to find specific file changes.</p><p>The Git directory is where Git stores the metadata and object database for your project. This is the most important part of Git, and it is what is copied when you clone a repository from another computer.</p><p>The working directory is a single checkout of one version of the project. These files are pulled out of the compressed database in the Git directory and placed on disk for you to use or modify.</p><p>The staging area is a simple file, generally contained in your Git directory, that stores information about what will go into your next commit. It’s sometimes referred to as the index, but it’s becoming standard to refer to it as the staging area.</p><p>The basic Git workflow goes something like this:</p><ol><li>You modify files in your working directory.</li><li>You stage the files, adding snapshots of them to your staging area.</li><li>You do a commit, which takes the files as they are in the staging area and stores that snapshot permanently to your Git directory.</li></ol><p>When you run git init in a new or existing directory, Git creates the .git directory, which is where almost everything that Git stores and manipulates is located. If you want to back up or clone your repository, copying this single directory elsewhere gives you nearly everything you need.</p><p>Here’s what it looks like:</p><pre>HEAD<br>branches/<br>config<br>description<br>hooks/<br>index<br>info/<br>objects/<br>refs/</pre><p>You may see some other files in there, but this is a fresh git init repository — it’s what you see by default.</p><p>The branches directory isn’t used by newer Git versions, and the description file is only used by the GitWeb program, so don’t worry about those.</p><p>The config file contains your project-specific configuration options.</p><p>The info directory keeps a global exclude file for ignored patterns that you don’t want to track in a .gitignore file.</p><p>The hooks directory contains your client- or server-side hook scripts.</p><p>The objects directory stores all the content for your database.</p><p>The index file is where Git stores your staging area information.</p><p>The refs directory stores pointers into commit objects in that data (branches),<em>Wait</em> 😮 ? How does Git know what branch you’re currently on…?</p><p>It keeps a special pointer called HEAD...</p><p>Let’s say that we have two branch Master and testing pointing into the some commit’s data history.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ZmZLjTp5-XRf3zlmkOogBg.png" /></figure><p>To switch to an existing branch, you run the git checkout command. Let’s switch to testing branch:</p><pre>$ git checkout testing</pre><p>This moves HEAD to point to the testing branch .</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*9-CIbpGLx-FDYEGJ3BHXbw.png" /></figure><p>Well, let’s do another commit:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Rp1SfWQ1GsHV31BJOC4J_Q.png" /></figure><p>This is interesting, because now your testing branch has moved forward, but your master branch still points to the commit you were on when you run git checkout to switch branches.</p><h3>Conclusion :</h3><p>You should have a pretty good understanding of what Git does in the back- ground and, to some degree, how it’s implemented.</p><p>Git as a content-addressable filesystem is a very powerful tool that you can easily use as more than just a VCS. I hope you can use your newfound knowledge of Git internals to implement your own cool application of this technology and feel more comfortable using Git in more advanced ways.</p><p>That was all for this part. In next part, I will write about some advanced git feature.</p><p><em>❤ Thanks for reading and follow me for more articles like this. If this post was helpful, please click the clap 👏 button</em> <em>❤</em></p><p><em>This post is based on </em><strong>Pro Git Scott Chacon.</strong></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=fe9f26cf4e87" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>