可以重命名分支



我正在研究一段时间的git(使用 gitlab.com)。
现在我明白了,最好为使用的分支使用另一个名称。

是否可以更改该分支名称 - 即使它有多个提交并且过去已经合并到另一个分支 - 本地和远程?

因为它是一个已经合并的"旧"分支,所以我无法构建一个新分支并删除旧分支。

是否可以更改该分支名称

# 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>

因为它是一个已经合并的"旧"分支,所以我无法构建一个新分支并删除旧分支。

如果您的分支已合并,并且您不再需要它,则可以在本地删除它:

git branch -D <oldname>

最新更新