壁球git从主题分支提交

时间:2016-06-09 18:44:59

标签: git

我有一个主题分支(通心粉),我已经提交了拉取请求。我不得不在反馈后做出改变。要求我将两个提交压缩成一个提交。这就是我所做的:

git status
On branch macaroni

git log
commit def  feedback fixes
commit abc  fix cheddar flavor

git rebase -i origin/master
.. go through screen where I pick commit to squash ..
.. go through screen where I update commit message ..

git log
commit abc fix cheddar flavor, squashing done!

此时我相信我必须使用-force标志来推送我的主题分支,因为我已经更改了历史记录:

git push -f

我正在使用这个问题的第二个答案:

Preferred Github workflow for updating a pull request after code review

带副标题"可选 - 清理提交历史记录"。作者最后提到你应该使用主题分支,不确定我是否应该更改任何命令,因为我已经在主题分支上。

我也担心因为我使用-f而意外强行将某些东西推到主分支上,因为我使用了-f,但是因为我在主题分支上,只有那个分支应该受到影响,对?

由于

3 个答案:

答案 0 :(得分:0)

检查

会发生什么
git push -f --dry-run

如果看起来没问题,那么用

执行实际命令
git push -f

查看push -f

会影响哪个分支
git branch -vv --list macaroni

答案 1 :(得分:0)

如果不确定,请在强制推送时使用显式远程名称和推送规范:

git push -f my-remote HEAD:macaroni

答案 2 :(得分:0)

push命令的行为可能会有所不同,具体取决于您的配置以及git版本。例如,如果你的版本是1.X git push默认推送所有匹配的分支,在你的场景中你可能也推动了主分支。

您需要检查的变量是:

push.default

您可能会发现this帖子很有用。