我正在尝试从多个提交(已经推送到origin / master)进行一次提交。
我正在尝试本教程: https://feeding.cloud.geek.nz/posts/combining-multiple-commits-into-one/
$ git log --oneline
c172641 Fix second file
24f5ad2 Another file
97c9d7d Add first file
we can combine the last two commits (c172641 and 24f5ad2) by rebasing up to the first commit:
$ git rebase -i 97c9d7d
and specify the following commands in the interactive rebase screen:
pick 24f5ad2 Another file
squash c172641 Fix second file
which will rewrite the history into this:
$ git log --oneline
1a9d5e4 Another file
97c9d7d Add first file
这很好用,直到我把它推到origin / master。
$ git pull
$ git push origin master
$ git log --oneline
RESULT IS:
******* Merge branch master...
******* THAT REBASE name...
c172641 Fix second file
24f5ad2 Another file
97c9d7d Add first file
但我想要这个结果:
$ git log --oneline
1a9d5e4 Another file
97c9d7d Add first file
这可能吗?
答案 0 :(得分:1)
在这种情况下,您可能需要强制推送而不是拉&推
$ git log --oneline
1a9d5e4 Another file
97c9d7d Add first file
$ git push -f origin master
注意:rebase
+ force push
会覆盖历史记录,请谨慎使用公共分支。