how can git checkout HEAD~2 go 10 commits back

回眸只為那壹抹淺笑 提交于 2019-12-01 14:47:35

Here's a simplified diagram:

...--o--*-----o------o--o   <-- you are here
         \          /
          o--o--o--o

You are at the marked commit, towards the right. You need to walk to the * commit towards the left, following one or the other lines, or maybe even following both at the same time. How many os will you traverse? How many os are there "between" commit * and the right hand edge one?

Now consider what happens with Git when there are merge commits (you must have some near the tip of your current branch, to be seeing this). The ~2 count walks back two commits on some particular line. What about all the commits on the other lines? What happens to them?

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!