开发者

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.

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.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜