如何在git中向后移动分支? [英] How to move a branch backwards in git?
本文介绍了如何在git中向后移动分支?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
假设我有一个开发正在进行几个提交c1,c2,...和3个分支A,B ,C
c1 - c2 - c3 - (B) - c4 - (A,C)
分支A和C在同一个提交中。
<现在我想让分支A回到B的位置,这样它就可以像这样:
c1 - c2- -c3 - (A,B) - c4 - (C)
重要的是,
解决方案
使用reset子命令:
git checkout A
git reset --hard B
git push --force github
作为旁注,当分支已经被推送到别处时,你应该小心使用 git reset
。这可能会给已经签出您的更改的用户造成麻烦。
The title is not very clear. What I actually need to do often is the following:
Let's say I have a development going on with several commits c1,c2,... and 3 branches A,B,C
c1--c2--c3--(B)--c4--(A,C)
Branch A and C are at the same commit.
Now I want branch A to go back where B is, so that it loks like this:
c1--c2--c3--(A,B)--c4--(C)
Important is that this has to happen locally and on github.
解决方案
Use the reset subcommand:
git checkout A
git reset --hard B
git push --force github
As a sidenote, you should be careful when using git reset
while a branch has been pushed elsewhere already. This may cause trouble to those who have already checked out your changes.
这篇关于如何在git中向后移动分支?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文