[英]Automatically Rebase and Squash Git History From a Commit ID to HEAD from Branch to Master
Is it possible to use git rebase
to remove all of the history from a specific commit to the HEAD revision? 是否可以使用git rebase
从特定提交到HEAD修订中删除所有历史记录?
With git -i rebase
, you have to count all of the commits in the git log
and manually get squash of all of them except one commit before pushing the changes. 使用git -i rebase
,您必须计算git log
中的所有提交,并手动获取除一次提交之前所有提交的压榨,然后再推送更改。
Is there a one-liner to do the following: 是否可以单线执行以下操作:
git rebase -i HEAD~4
for 4 commits git rebase -i HEAD~4
提交4次 git fetch origin
to update the references git fetch origin
更新参考 git rebase origin/master
to rebase the branch onto the master git rebase origin/master
将分支重新建立到master git checkout master
to switch to the master branch git checkout master
切换到master分支 git merge branch_name
to merge the branch onto the master git merge branch_name
将分支合并到主git merge branch_name
上 Is it possible to do this with less steps or other flags? 是否可以用更少的步骤或其他标志来做到这一点?
除了git rebase -i
您还可以运行git rebase --soft <commit-id>
将HEAD
移到<commit-id>
而不更改索引或工作树,然后git commit
创建一个新的提交,其中包含自<commit-id>
。
I believe what you're after is git commit --fixup . 我相信您所追求的是git commit --fixup 。 Thoughtbot's writeup on automating this might interest you. Thoughtbot关于自动执行此操作的文章可能会让您感兴趣。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.