Is the SHA-1 of commits calculated based only on the content of the tree?

前端 未结 3 499
有刺的猬
有刺的猬 2020-12-03 08:21

For the sake of an experiment, lets say your git log identifies the following commits

commit 16bc8486fb34cf9a6faf0f7df606ae72ad9ea438  // added          


        
3条回答
  •  臣服心动
    2020-12-03 09:14

    The SHA1 is calculated from the diff and all meta data from this commit (including the author and committer, the timestamp, and various other data).

    For your second question, the data commit is still present but not part of any live branch anymore. Sometimes git will run a garbage collection where various deleted stuff will actually be removed. You will notice that once you manually run it using git gc that the unreferenced commit will be gone and not even be accessible with git show anymore.

提交回复
热议问题