我可以用一个命令销毁并重新创建Git远程分支吗? [英] Can I destroy and recreate a Git remote branch in one command?
本文介绍了我可以用一个命令销毁并重新创建Git远程分支吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
重新绑定后,我无法将之前推送的分支推送到遥远的,因为我的分支的历史不再与远程的那个分支的历史一致。所以我必须先删除它。
这是我目前的工作流程:
git checkout my_branch
git rebase master
git push origin:my_branch#删除分支的远程版本
git push origin my_branch#在此分支上推出我的新版历史记录
是否有可以替换最后两个命令的单个原子命令?
解决方案
如果允许您重写远程分支,您可以使用 git push --force my_remote my_branch
。
In Git, I sometimes work on long-running branches. I like to rebase on master from time to time to make merging easier when I'm ready.
After rebasing, I can't push a previously-pushed branch to a remote, because my branch's history no longer agrees with the remote's history of that branch. So I have to delete it first.
This is my current workflow:
git checkout my_branch
git rebase master
git push origin :my_branch # Delete remote version of the branch
git push origin my_branch # Push up my new version of history on this branch
Is there a single, atomic command that could replace the last two commands?
解决方案
If you are allowed to rewrite the remote branch, you can use git push --force my_remote my_branch
.
这篇关于我可以用一个命令销毁并重新创建Git远程分支吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文