How does Git save edited files from a commit?

Asked

Viewed 85 times

0

I understood that git add creates the hash of the changed files in the project and adds this hash as a reference to staging. In the git commit it creates a hash for all project files, saves as a Tree and creates a commit object with this Tree hash, the previous commit hash, etc. However, at no time does it reference edited files.

How Git knows which files have been edited into a commit?

  • 1

    maybe help https:/shalithasuranga.medium.com/how-does-git-work-internally-7c36dcb1f2cf

1 answer

-2

I believe that to complement Francisco’s response, every file that is handled by git is generated a SHA key, from its blobs and Tree, is a tangle of SHA, becoming unique to each file, and any different given space in the file, changes that SHA, and if by chance, If you manage to go back exactly to the previous situation, the SHA will also be the same again. So Git can tell if something has been manipulated in the file. Commits are for you to comment and know visually what has been done.

Note: SHA is a unique 40-character encrypted key to what is done in the document.

Although it is wikipedia, it explains better what SHA is. https://pt.wikipedia.org/wiki/Secure_Hash_Algorithms

Browser other questions tagged

You are not signed in. Login or sign up in order to post.