GIT Internal (Part 3)

GIT Internal (Part 3)

Hi everyone, today I’ll continue the series about Git Internal. Let’s dive into the Git commit flow and test the theory with hands-on experiments.

How Git tracks changes

  • When we work with source code, we are working in the working directory (which is the folder containing the .git folder).
  • After we modify the code, we want to save those changes, and they will be stored in the Repository (image 1).

Repository and Working Dir

  • However, the code doesn’t go straight from the Working Directory to the Repository; it has to go through an intermediary stage called the Index or Staging Area.

Staging Area

  • Files in the working directory have two states: Tracked and Untracked. Tracked files are those that have been committed or are in the staging area, while Untracked files are the rest.

Tracked and Untracked state

Testing the theory

Enough theory, now let’s verify it with some hands-on testing.

  • First, I’ll initialize a repository named repo_1 using the command "git init repo_1". To check the result of the above command, we can use the command "tree /f .git".

  • The result shows the structure of the files in the .git folder. Let’s create any file in the folder, for example, using the command: echo hello > new_file.txt.

  • Next, we’ll add and commit the newly created file, and then run the tree /f .git command again to see the changes.

  • There are many changes now. Pay attention to the objects folder: hashes with the same first two characters are grouped into a folder with that name.
  • Notice that the logs folder records the history of actions like commit, merge, rebase, reset, etc., while the refs folder contains branch and tag pointers, and the objects folder stores the objects.

Thank you for following along!


要查看或添加评论,请登录

Huy Nguyen的更多文章

  • 0.01 và 0.25 ^ 4

    0.01 và 0.25 ^ 4

    Hello m?i ng??i. Cu?i tu?n th? 7 v?a r?i mình có m?t bu?i offline v?i c?ng ??ng wecommit.

    1 条评论
  • Domain-driven design - Tactical design

    Domain-driven design - Tactical design

    Tóm t?t DDD M?c tiêu c?a DDD là thi?t k? ph?n m?m ??t nghi?p v? vào trung tam, tách bi?t nghi?p v? v?i c?ng ngh?. DDD…

  • Gi?i thi?u AI và Machine learning

    Gi?i thi?u AI và Machine learning

    Hello ace, h?m T7 v?a r?i mình có offline nhóm wecommit, n?i dung v? Gi?i thi?u AI và Machine learning. Bu?i chia s?…

    2 条评论
  • MVCC trong postgresql

    MVCC trong postgresql

    MVCC trong postgresql là gì MVCC (Multi-Version Concurrency Control) là c? ch? ki?m soát concurrency ?? x? lí nhi?u…

  • Event storming cùng microservice và Domain driven design

    Event storming cùng microservice và Domain driven design

    Hello m?i ng??i, th? 7 v?a r?i mình có bu?i chia s? v?i anh em wecommit v?i ch? ?? "Event storming cùng microservice và…

    7 条评论
  • Free talk: L?p trình viên chuyên nghi?p

    Free talk: L?p trình viên chuyên nghi?p

    Hello anh em, ngày h?m qua mình l?i có bu?i off cùng anh em wecommit. Ch? ?? tu?n này là v? "L?p trình viên chuyên…

  • Làm sao ?? làm quen d? án m?i m?t cách nhanh nh?t

    Làm sao ?? làm quen d? án m?i m?t cách nhanh nh?t

    Hello anh em, tu?n v?a r?i mình v?a có 1 bu?i offline c?ng ??ng we commit. B?n cu?i tu?n OT nên nay mình m?i có th?i…

  • Loay hoay ch?n h??ng ?i, làm tech lead hay làm qu?n ly?

    Loay hoay ch?n h??ng ?i, làm tech lead hay làm qu?n ly?

    H?m nay mình l?i có d?p ng?i cùng anh em wecommit ?? bàn lu?n ch? ?? này. Mình hi?n ?ang là m?t middle dev, và c?ng…

    7 条评论
  • Phan m?nh index trong database

    Phan m?nh index trong database

    Khi update data trong b?ng th??ng xuyên có th? làm index b? phan m?nh, gay ra v?n ?? v? hi?u n?ng khi truy xu?t d?…

    1 条评论
  • B Tree và database index

    B Tree và database index

    Bài vi?t giúp b?n hi?u v? c?u trúc B Tree, B+Tree, cách index ho?t ??ng trong database, và t?i sao GUID dùng làm PK là…

    6 条评论

社区洞察

其他会员也浏览了