Git: Difference between two very similar commits?

I need to know why the two commits are different. I have two commits, e2383d and 2c44ab, which, apparently, since they have different hashes, different.

First, I know about git diff , and I'm currently trying to git diff e2383d 2c44ab . He returns successfully, with no withdrawal. Two commits have:

  • Same commit message
  • Same author
  • Same commit date ( changed: sorry, just a date, see my answer below)
  • Same parent
  • The same as far as I can tell.

Basically, my tree looks like this:

 * ← stuff based on that commit | * ← e2383d * | ← 2c44ab |/ * ← the common parent 

I am going to eliminate e2383d, but before I do this, I would like to make sure that there is nothing important there. My understanding of git , however, is that if the two β€œcommits” were the same, they have the same hash, and thus my situation would not exist unless there was a difference between the two.

One more thing I tried:

 % diff <(git show 2c44ab) <(git show e2383d) 1c1 < commit 2c44ab... --- > commit e2383d... 

Forgotten who has> 1 date. The following command showed (for me) the difference between my two commits:

 % diff <(git show --pretty=fuller 2c44ab) <(git show --pretty=fuller e2383d) 1c1 < commit 2c44ab96bde429c9f345d8a12dfcf2278faa9333 --- > commit e2383d3164589bb3a8a679c9cb6bbe93ea41e2ee 5c5 < CommitDate: Wed Nov 23 17:06:40 2011 -0800 --- > CommitDate: Mon Nov 28 11:41:26 2011 -0800 

The commit date for Monday is the time I did the reinstall. Now, why git saves this - it seems to win the "This is the same as I will add" behavior that I expected.

+4
source share
1 answer

Two commits can have the same tree, but different metadata. Each time a commit is corrected, reinstalled or cherry is selected, the commit date is updated and a new commit is written.

If git says that the diff between commits A and B is empty, but you are still not sure, you can see for yourself that they point to the same tree with

 git rev-parse A^{tree} B^{tree} 

which lists the names of their tree objects or

 git cat-file -p A git cat-file -p B 

which will show you raw commit objects.

+2
source

Source: https://habr.com/ru/post/1383515/


All Articles