我合并到master时没有挤压,现在它显示了对分支myTestBranch
所做的每个提交。
有什么办法可以修复它以显示单个提交?
答案 0 :(得分:0)
您可以尝试使用rebase
,但是如果存储库被多个开发人员使用,请尝试进行协调,因为它会更改/更改存储库的历史记录,例如:
$ git rebase -i <commit>
<commit>
是您要返回/还原的提交的哈希值,在这里,您可以使用它来获取上次提交的列表:git log --pretty=oneline --abbrev-commit
使用选项-i
(交互)进行基础调整时,它将打开您的编辑器并显示以下内容:
pick 447dae2 my changes for foo bar
pick 452b764 1
pick 9aaf8b3 2
pick 15a6af0 3
pick f31a830 4
pick dd34521 5
# Rebase 5302aa0..dd34521 onto 5302aa0 (6 commands)
#
# 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
# d, drop = remove commit
因此,您可以在此处添加前缀前缀来“修正”或“压扁”,例如:
pick 447dae2 my changes for foo bar
f 452b764 1
f 9aaf8b3 2
f 15a6af0 3
f f31a830 4
f dd34521 5
# Rebase 5302aa0..dd34521 onto 5302aa0 (6 commands)
#
# 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
# d, drop = remove commit
然后您将需要推力:
$ git push -f
您的梨,可能需要做:
$ git pull --rebase
请查看此答案以获取更多详细信息:https://stackoverflow.com/a/42862404/1135424