0

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?

gib
  • 3
  • 1

2 Answers2

3

Yes. It's common. Here are some cases in which you can create new commits that point at the same tree with another commit.

  1. 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.

  2. git commit && git revert to create a revert commit that has the same tree with its parent's parent.

  3. git commit-tree ${foo}^{tree} to create a commit that has the same tree with foo. foo is a commit-ish.

  4. Based on the same commit, commit the same changes. Repeating the steps, you get different commits that point at the same tree.

ElpieKay
  • 27,194
  • 6
  • 32
  • 53
2

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.

eftshift0
  • 26,375
  • 3
  • 36
  • 60