I know that multiple git-trees can point to the same blob. This happens, when we only change the filename and do a commit again. But can there be git commits, that point to the same tree? If yes, when does it occur?
2 Answers
Yes. It's common. Here are some cases in which you can create new commits that point at the same tree with another commit.
Use
git commit --allow-empty
to create an empty commit that has the same tree with its parent. An empty commit does not have any changes.git commit && git revert
to create a revert commit that has the same tree with its parent's parent.git commit-tree ${foo}^{tree}
to create a commit that has the same tree withfoo
.foo
is a commit-ish.Based on the same commit, commit the same changes. Repeating the steps, you get different commits that point at the same tree.

- 27,194
- 6
- 32
- 53
-
2Also: `git merge -s ours`. – torek Jun 02 '21 at 04:43
Sure...... a commom one, without thinking too hard: when you revert revisions, if you end up with the same tree (or several along the way of reverting many revisions)... well, there you have it.

- 26,375
- 3
- 36
- 60