开发者

How exactly does git checkout affect commits and stashes?

I'm not finding my answer in the online git lit.

It is clear that git checkout is destructive in that it will throw away local modifications but does it also destroy开发者_运维问答 commits by changing the structure of the tree? For example, say I have three commits

a <-- b <-- c
            |
           HEAD

+ stash c

and HEAD is currently at c and I've stashed all uncommitted changes.

If I do "git checkout HEAD^" I would naively expect this to take me from one head to another i.e. the state of the tree should be:

a <-- b <-- c
      |
     HEAD

+ stash b

where "stash b" is whatever was stashed at commit b.

But it seems from my experimentation that the actual result is

a <-- b
      |
     HEAD

+ stash b

i.e. commit c is "pruned" from the tree or is at least not showing up in "git log".

Am I getting this completely wrong? Is the answer to this question obvious from the git manuals?


A commit doesn't reference the child, only the parent. And more than one child can have the same parent.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜