git checkout 究竟如何影响提交和存储?
我没有在在线 git lit 中找到答案。
很明显, git checkout 具有破坏性,因为它会丢弃本地修改,但它是否也会通过更改树的结构来破坏提交?例如,假设我有三个提交
a <-- b <-- c
|
HEAD
+ stash c
,并且 HEAD 当前位于 c,并且我已经隐藏了所有未提交的更改。
如果我执行“git checkout HEAD^”,我会天真地期望这会将我从一个头带到另一个头,即树的状态应该是:
a <-- b <-- c
|
HEAD
+ stash b
其中“stash b”是在提交 b 处隐藏的任何内容。
但从我的实验来看,实际结果似乎是,
a <-- b
|
HEAD
+ stash b
即提交 c 从树中“修剪”了,或者至少没有出现在“git log”中。
我完全错了吗?这个问题的答案从 git 手册中显而易见吗?
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?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
提交不引用子级,仅引用父级。并且多个孩子可以有同一个父母。
A commit doesn't reference the child, only the parent. And more than one child can have the same parent.