DevOps Classroom Series – 25/Nov/2021

How Git Works

  • Git is a stupid content tracker
  • To understand git lets first understand hashing.
  • Hashing is the process of converting a given key/text (any length) into another smaller value (fixed size string or number).
  • Hashing algorithms
    • md5
    • SHA1
    • SHA256
  • Git Use SHA1 hashing to track contents
  • Lets go to .git/HEAD which will point towards a branch (.git/refs/heads/<branch>)
  • In the branch file we will have the latest commit id of the branch
  • The plumbing command git cat-file -t <id> will show the type and git cat-file -p <id> will print the contents
  • In Git we have following types
    • tree:
      • This represents a folder or directory
    • blob:
      • This represents a file
    • commit:
      • This represents a commit
  • Commit is SHA-1 Hash of
    • contents (Changes)
    • author
    • message
    • parent commit
  • Lets use some plumbing commands on master and try to build the tree Preview Preview Preview Preview
  • Since we have a basic idea, lets create a new git repository and then create three commits Preview
  • For commands used refer classroom video
  • Lets try to create a branch ‘develop’ make one commit in it and also one commit in master branch. then merge the chagnes from develop to master branch Preview
  • As of now we are good with three areas of git Preview
  • Next Steps:
    • Lets focus on fourth area of git i.e. Remote Repositories Preview

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.

About learningthoughtsadmin