ome*_*erk 53 git github squash pull-request
我在GitHub上发了一个pull请求.现在,存储库的所有者正在说要将所有提交压缩成一个.
当我键入git rebase -iNotepad打开时,其中包含以下内容:
noop
# Rebase 0b13622..0b13622 onto 0b13622
#
# 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
#
# These lines can be re-ordered; they are executed from top to bottom.
#
# If you remove a line here THAT COMMIT WILL BE LOST.
#
# However, if you remove everything, the rebase will be aborted.
#
# Note that empty commits are commented out
Run Code Online (Sandbox Code Playgroud)
我在谷歌搜索但我不明白该怎么做.
fon*_*tno 48
只是一个简单的补充,以帮助其他人寻找此解决方案.您可以传递您想要压缩的先前提交的数量.例如,
git rebase -i HEAD~3
Run Code Online (Sandbox Code Playgroud)
这将在编辑器中显示最后3次提交.
ome*_*erk 38
好吧,我想通了......首先我必须写下git rebase -i xxxxxxxxxxxxxxxxxxxxxxxxxx是我要压缩的提交的SHA.然后在记事本中我编辑了第一个作为壁球的选择和休息.然后会出现一个新的记事本窗口,在第一行中我输入了我的新提交的名称.然后我不得不做推力:
git push --force origin master
Run Code Online (Sandbox Code Playgroud)
从2016年4月1日开始,存储库管理器现在可以通过在拉取请求中选择"Squash and merge"来将拉取请求中的所有提交压缩到单个提交中.
当然,如果您仍然想在合并之前手动压缩提交,则fontno的答案是最佳解决方案.
尝试git rebase -i,并使用'squash'进行您想要压缩的所有提交.
编辑:
git rebase -i将向您显示一个交互式编辑器,其中包含您正在重新定位的提交列表.每次提交之前的默认命令是"pick",所以你只需要s/pick/squash /用于你想要压缩的所有提交,然后所有这些提交将被压缩到他们上一次提交之前.
确保您在正确的分支上进行变基础.
| 归档时间: |
|
| 查看次数: |
36317 次 |
| 最近记录: |