如何在 git 中重命名和移动分支(bitucket/sourcetree)



我们有一个名为ABC-Awsome_Branch的分支,它在feature/3.0.0中是"保存"的,所以它看起来像:feature/3.0.0/ABC-Awsome_Branch

但是分支是使用不正确的名称创建的,甚至不在正确的文件夹中。所以正确的路径/名称必须是这样的:feature/2.5.0/DEF-Awsome_Branch。现在这个分支包含一些提交等...

是否可以"移动"并将分支重命名为正确的名称和路径?

我们使用Bitbucket和源代码树。

这应该可以解决问题:

git branch -m old_branch new_branch         # Rename branch locally    
git push origin :old_branch                 # Delete the old branch    
git push --set-upstream origin new_branch   # Push the new branch, set local branch to track the new remote

来源在这里

在执行此操作之前不要忘记拉动,这样您就不会丢失以前未拉取的任何内容。

最新更新