2011-10-30 43 views
63

在git的樞紐我重新添加標籤:git的標籤刪除並做重新添加

git tag -d 12.15 
git push origin :refs/tags/12.15 
git tag -a 12.15 -m '12.15' 
git push --tags 

標籤仍然是指在GitHub上的舊標籤,但當地是做正確的。

更新:看來github列出了最後一次提交錯誤,但正確下載。

+13

'git tag -d'刪除一個標籤。其實我是來這裏尋找... :) –

回答

65

的引用https://stackoverflow.com/a/5480292/1317035

你只需要按下一個 '空' 參考遠程標記名稱:

git push origin :tagname 

或者,更傳神,使用--delete選項:

git push --delete origin tagname 

將分支,標記或其他引用推送到遠程存儲庫涉及指定「推送哪裏,什麼源,什麼目的地?」

git push where-to-push source-ref:destination-ref 

,你把你的master分支到原點的主分支一個真實世界的例子是:

git push origin refs/heads/master:refs/heads/master 

這是因爲默認路徑,可以縮短爲:

git push origin master:master 

標籤以同樣的方式工作:

git push refs/tags/release-1.0:refs/tags/release-1.0 

通過省略源ref(冒號前的部分),將'nothing'推送到目的地,刪除遠端的ref。

+3

爲什麼加入':'工程的好信息..謝謝.. –

+0

@guymograbi你可以在這裏找到更多信息http://git-scm.com/docs/git-按#OPTIONS – nickleefly