我知道git push --tags
是一個與普通舊git push
分開的操做的緣由。 推進標籤應該是一個有意識的選擇,由於你不想意外推進標籤。 不要緊。 但有沒有辦法將二者結合在一塊兒? (除了git push && git push --tags
。) git
從git 2.4.1開始 ,你能夠作到 fetch
git config --global push.followTags true
若是設置爲true,則默認啓用--follow-tags選項。 您能夠經過指定--no-follow-tags在推送時覆蓋此配置。 atom
從git 1.8.3(2013年4月22日)開始 , 您再也不須要執行2個命令來推送分支,而後推送標籤 : url
新的「
--follow-tags
」選項告訴「git push
」 在推出分支時推送相關的註釋標籤 。 spa
您如今能夠在推送新提交時嘗試: .net
git push --follow-tags
這不會推送全部本地標籤,只有經過git push
提交引用的標籤。 命令行
Git 2.4.1 +(2015年第2季度)將引入選項push.followTags
:請參閱「 如何製做」 git push
「在分支中包含標籤? 」。 code
核選項將是git push --mirror
,它將在refs/
下推送全部引用。 rem
您還可使用當前分支提交僅推送一個標記: get
git push origin : v1.0.0
您能夠將--tags
選項與--tags
結合使用,例如:
git push origin --tags :
(由於--tags
意味着: 除了在命令行中明確列出的 --tags
以外 , 還會推送 refs/tags
下的全部引用)
您還有此條目「 使用單個」推送分支和標籤「git push」調用 「
一個方便的提示剛剛被ZoltánFüzesi發佈到Git郵件列表中 :
我使用
.git/config
來解決這個問題:
[remote "origin"] url = ... fetch = +refs/heads/*:refs/remotes/origin/* push = +refs/heads/* push = +refs/tags/*
添加這些行後,
git push origin
將上傳全部分支和標籤。 若是您只想上傳其中一些,能夠枚舉它們。尚未嘗試過,但看起來它可能會有用,直到同時推送分支和標籤的其餘方式添加到git push。
另外一方面,我不介意打字:
$ git push && git push --tags
請注意 , Aseem Kishore 評論道
push = +refs/heads/*
將強制推送全部分支 。
剛纔這就是我,因此我是。
RenéScheibe添加了這個有趣的評論 :
--follow-tags
參數具備誤導性,由於只考慮.git/refs/tags
下的.git/refs/tags
。
若是運行git gc
,標籤將從.git/refs/tags
到.git/packed-refs
。 以後git push --follow-tags ...
再也不按預期工做了。
也許這有助於某人:
1. git commit -a -m "msg" 2. git tag 0.1.0 // creates a new tag locally 3. git push origin tag 0.1.0 // pushes the tag & the code in the remote repo
Git GUI有一個PUSH按鈕 - 原諒雙關語,它打開的對話框有一個標籤複選框。
我從命令行推了一個分支,沒有標籤,而後再次嘗試使用上面描述的--follow-tags
選項推進分支。 該選項被描述爲如下帶註釋的標籤。 個人標籤是簡單的標籤。
我修復了一些東西,用修復標記了提交,(因此同事能夠選擇修復),而後更改了軟件版本號並標記了我建立的版本(所以同事能夠克隆該版本)。
Git回來講一切都是最新的。 它沒有發送標籤! 也許是由於標籤沒有註釋。 也許是由於分支上沒有什麼新東西。
當我使用Git GUI進行相似的推送時,標籤被髮送了。
目前,我將使用Git GUI將個人更改推送到個人遙控器,而不是使用命令行和--follow-tags
。
@since Git 2.4
git push --atomic origin <branch name> <tag>