What's the difference between HEAD^ and HEAD~ in Git?

前端 未结 16 2201
醉酒成梦
醉酒成梦 2020-11-22 10:43

When I specify an ancestor commit object in Git, I\'m confused between HEAD^ and HEAD~.

Both have a \"numbered\" version like HEAD^3<

16条回答
  •  天命终不由人
    2020-11-22 11:34

    The ^ format allows you to select the nth parent of the commit (relevant in merges). The ~ format allows you to select the nth ancestor commit, always following the first parent. See git-rev-parse's documentation for some examples.

提交回复
热议问题