2016-03-20 67 views
2

我正在使用git一段時間(使用gitlab.com)。
現在我明白了,最好爲使用的分支使用另一個名稱。重命名分支可能嗎?

是否可以更改該分支名稱 - 即使它有多個提交,並且已經合併到過去的另一個分支 - 本地和遠程?

因爲它是一個'舊'分支,它已經被合併,我不能建立一個新分支並刪除舊分支。

+0

舊合併分支通常會被刪除,爲什麼你需要有一個新名稱代替? – choroba

+0

這是錯誤的名稱,它顯示在網絡圖(提交 - >網絡) – user3142695

回答

1

是否有可能改變分支名

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