Git:将其他分支重置为当前没有结帐 [英] Git: reset other branch to current without a checkout
本文介绍了Git:将其他分支重置为当前没有结帐的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我需要将其他(现有)分支重置为当前分支,而无需签出。
之前:
CurrentBranch:提交A
OtherBranch:提交B
后:
CurrentBranch:commit A
OtherBranch:commit A
等效于
$ git checkout otherbranch
$ git reset --soft currentbranch
$ git checkout currentbranch
code>
(注--soft:我不想影响工作树。)
这是可能的吗?
解决方案
您描述的工作流程并不相同:当您执行重置--hard
你在工作树中失去了所有的变化(你可能想把它变成 reset --soft
)。
您需要的是
git update-ref refs /头/ OtherBranch裁判/头/ CurrentBranch
I'm writing some scripts for my Git workflow.
I need to reset other (existing) branch to the current one, without checkout.
Before:
CurrentBranch: commit A
OtherBranch: commit B
After:
CurrentBranch: commit A
OtherBranch: commit A
Equivalent of
$ git checkout otherbranch
$ git reset --soft currentbranch
$ git checkout currentbranch
(Note --soft: I do not want to affect working tree.)
Is this possible?
解决方案
The workflows you describe are not equivalent: when you perform reset --hard
you lose all the changes in the working tree (you might want to make it reset --soft
).
What you need is
git update-ref refs/heads/OtherBranch refs/heads/CurrentBranch
这篇关于Git:将其他分支重置为当前没有结帐的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文