我如何将最后的N承诺集成到一个承诺中?


当前回答

2020年简单的解决方案:

git reset --soft HEAD~2 
git commit -m "new commit message"
git push -f

2 意味着最后两个命令将被打破,你可以用任何数字取代它。

其他回答

尝试了所有方法提到的这里. 但最终我的问题解决了通过遵循这个链接. https://gist.github.com/longtimeago/f7055aa4c3bba8a62197

$ git fetch upstream
$ git checkout omgpull 
$ git rebase -i upstream/master

 < choose squash for all of your commits, except the first one >
 < Edit the commit message to make sense, and describe all your changes >

$ git push origin omgpull -f

如果您正在与 GitLab 合作,您可以按下面的 Merge 请求中的 Squash 选项,承诺消息将是 Merge 请求的标题。

此分類上一篇

最方便的方式是使用 GitHub 桌面. 只需在历史中选择所有命令,右键单击并选择“Squash x 命令”:

此分類上一篇

我认为最简单的方式来做到这一点是通过创建一个基于大师的新分支,并进行功能分支的合并。

git checkout master
git checkout -b feature_branch_squashed
git merge --squash feature_branch

然后,你有所有的变化准备好进行。

简单的解决方案:

git reset --soft HEAD~5

git commit -m “委托信”

git push 起源分支 --force-with-lease