可以重命名分支吗?
Renaming branch possible?
我正在研究 git 一段时间(使用 gitlab.com)。
现在我明白了,最好为已用分支使用另一个名称。
是否可以更改该分支名称 - 即使它有多个提交并且过去已经合并到另一个分支 - 本地和远程?
因为是'old'分支,已经合并了,不能新建删除旧的
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.
如果您的分支已合并并且您不再需要它,您可以在本地删除它:
git branch -D <oldname>
我正在研究 git 一段时间(使用 gitlab.com)。
现在我明白了,最好为已用分支使用另一个名称。
是否可以更改该分支名称 - 即使它有多个提交并且过去已经合并到另一个分支 - 本地和远程?
因为是'old'分支,已经合并了,不能新建删除旧的
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.
如果您的分支已合并并且您不再需要它,您可以在本地删除它:
git branch -D <oldname>