2 Mar 2016

Understanding what GIT does under the hood rather than only learning commands and wondering

you can only really use Git if you understand how Git works

Repository

You get a .git folder when you do git init or git clone for the first time. That's your repository. Sometimes also referred to as local repository.

A git repository contains, among other things, the following:
  • A set of commit objects.
  • A set of references to commit objects, called heads (branch, tag and SHA1 names are types of head).

Remote Repository

If you have cloned from somewhere, so the URL/path (yes it can be local or on network also) you used to clone contains your remote repository. It is identical to what you get in your .git folder after cloning. `git remote -v` command lists all remotes available in the current repository and it's URL.

How GIT stores your commits or commit objects

A commit object contains 3 main things:
  • Reference to the parent commit
  • Changes  (adds/updates/deletes of words/lines/files) since parent commit or changes of this commit (it doesn't store whole file as it happens in centralized Version Control Systems like SVN/TFS/VSS/Perforce)
  • An SHA1 name(38f7a44232faf4651dc085495e4ea770c951d7b2), a 40-character string that uniquely identifies the commit object. The name is composed of a hash of  relevant aspects of the commit i.e. changes, timestamp, parent commit SHA1 name, author etc.

Branches

Branches are basically references of commits or easy way to refer to commits i.e. ugly SHA1 name. In some of the cases when you merge/rebase, these markers for SHA1 name move from one commit to another commit rather than moving/modifying around multiple commits. We will get to know more about it in upcoming parts of this series.

Credits: This post is inspired by Understanding Git Conceptually.

15 comments:

  1. vIt was a great information and Its really worth reading it. The author did an mind blowing work by describing each and every concept in detail. Thanks for such an informative post. Please keep up your good work.
    ECE Colleges in Chennai

    ReplyDelete
  2. Its great Article!!! I have a getting the some good massage in your post, Thank you for sharing your great information...Keep do this kind off articles.

    Professional Website Development Companies Bangalore | Top Website Design Company In Bangalore | Best Website Development Services Bangalore

    ReplyDelete
  3. This comment has been removed by the author.

    ReplyDelete
  4. This is very helpful. This gives great understanding of how Git repository functions.

    ReplyDelete
  5. Hi,
    Thanks for sharing a very interesting article about Understanding what GIT does under the hood rather than only learning commands and wondering. This is very useful information for online blog review readers. Keep it up such a great article like this.

    Regards,
    WondersMind,
    Web Design Company Bangalore

    ReplyDelete
  6. First this is a really Creative and Unique Article. Well, the main reason of me sharing my post here is that, We being the Digital Marketing Company In India are open for Partnerships with Mobile App Development, Website Development and Graphics related company !

    Get in touch with the Digital Marketing Services In India for more information

    ReplyDelete
  7. This comment has been removed by the author.

    ReplyDelete
  8. Web developers are the future of technologies

    https://cuion.in/

    ReplyDelete