我在 git 上工作了一段时间(使用 gitlab.com)。
现在我明白了,最好为已用分支使用另一个名称。
是否可以更改该分支名称 - 即使它有多个提交并且过去已经 merge 到另一个分支 - 本地和远程?
因为它是一个“旧”分支,已经被 merge 了,所以我不能建立一个新分支并删除旧分支。
最佳答案
Is it possible to change that branch name
# use the -m flag for move
git branch -m <oldname> <newname>
# now you have to push the new branch to the server
git push origin <newname>
# delete the old remote branch
git push origin --delete <oldname>
Because it is a 'old' branch, which has already being merged, I can't build a new one and delete the old one.
如果您的分支已 merge 并且您不再需要它,您可以在本地删除它:
git branch -D <oldname>
关于git - 可以重命名分支吗?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36111306/