我正在为我的 Git 工作流程编写一些脚本。
我需要将其他(现有)分支重置为当前分支,而无需签出。
Before:
CurrentBranch: commit A
OtherBranch: commit B
After:
CurrentBranch: commit A
OtherBranch: commit A
相当于
$ git checkout otherbranch
$ git reset --soft currentbranch
$ git checkout currentbranch
(Note --soft
:我不想影响工作树。)
这可能吗?
Set otherbranch
指向相同的提交currentbranch
通过跑步
git branch -f otherbranch currentbranch
The -f
(强制)选项告诉git branch
是的,我真的想覆盖任何现有的otherbranch
与新的参考.
来自文档 http://git-scm.com/docs/git-branch:
-f
- 力量
如果已经存在则重置为。如果没有 -f gitbranch 拒绝更改现有分支。
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)