我的git日志显示了前4个提交。第一个提交是在我尝试推送代码时形成的,它要求我先拉出代码,然后再推送。(基本上是合并了)。
commit 71c136f44e5bddd358d86277da730229d871f48c
Merge: d896439 fe59f57
Author: Ankit Gupta <ankit.gupta8898@gmail.com>
Date: Sat Jul 6 21:06:01 2013 +0100
Merging
commit d896439d1a33e6c0f3c78f1bf4ad731941c3c0bd
Author: Ankit Gupta <ankit.gupta8898@gmail.com>
Date: Sat Jul 6 21:03:20 2013 +0100
Message1
commit fe59f57bec7eb2764c4c4e5cd1f5fdc21001bcc5
Author: Ankit Gupta <ankit.gupta8898@gmail.com>
Date: Sat Jul 6 21:03:20 2013 +0100
Message 2
commit caa12dab636587a741ebc97c4e461d1618de55f9
Author: Ankit Gupta <ankit.gupta8898@gmail.com>
Date: Fri Jul 5 16:20:54 2013 +0100
Message 3我想将所有这4个提交都压缩到最新的(71c136)中,当我执行git rebase -i HEAD~4时,它会显示我
pick 56e3419 Message 4
pick caa12da Message 3
pick d896439 Message 2
pick fe59f57 Message 1
# Rebase ebabdfb..71c136f onto ebabdfb
#
# Commands:
# p, pick = use commit
# r, reword = use commit, but edit the commit message
# e, edit = use commit, but stop for amending
# s, squash = use commit, but meld into previous commit
# f, fixup = like "squash", but discard this commit's log message
# x, exec = run command (the rest of the line) using shell
#为什么它没有列出第一个提交,以及如何压缩所有4个提交?
发布于 2013-07-07 06:57:25
要将所有四个提交合并为一个提交,您可以遵循类似于“git: how to insert a commit as the first, shifting all the others?”中描述的方法:
git symbolic-ref HEAD refs/heads/newroot
git rm --cached -r .
git clean -f -d
# All commits should be listed then: you can squash them
git rebase --interactive --onto newroot --root master
git branch -d newroothttps://stackoverflow.com/questions/17507507
复制相似问题