简体   繁体   English

如何解决这些虚假的git commit?

[英]How do I fix these spurious git commits?

I made an error when I was working and wound up with a commit tree I didn't want. 我在工作时犯了一个错误,并用了我不想要的提交树。 Right now, things look like this: 现在,事情看起来像这样:

[master]
        A -- B -- C -- D
              \
               \
                C' -- D'
                      [HEAD]

I want to wind up like this: 我想这样结束:

                        [master, HEAD]
        A -- B -- C -- D

How do I get there from here? 我怎么从这里到达那里?

OK, you're on a detached HEAD, and you want to be on master (currently at A), but with master at D which is a direct descendant. 好的,您在独立的HEAD上,并且想要成为主服务器(当前在A),但要在D的主服务器上是直接后代。

git checkout master

# This will fast-forward master to D
git merge D

D' and C' will no longer be on any branch so they won't be visible and will eventually be garbage collected. D'和C'将不再在任何分支上,因此它们将不可见,并最终被垃圾回收。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM