新增 tag
指令格式:git tag [-a | -s | -u <keyid>] [-f] [-m <msg> | -F <file>] <tagname> [<commit> | <object>]沒加特別的參數則是新增名為 <tagname> 的 lightweight tag 到目前送交,可用 <commit> 或 <object> 指定 tag 是要加到哪個送交。
加參數 -a、-s、或 -u <keyid> 的話都是用來新增 annotated tag,這三者不同在於 -a 沒有簽名,-s 是用目前使用者的簽名,-u <keyid> 是用 <keyid> 的簽名。annotated tag 需要加訊息,會跳出編輯器輸入,或用 -m <msg> 透過指令行加訊息,或用 -F <file> 自檔案取得訊息。由於 annotated tag 才能加訊息,沒有 -a、-s、或 -u <keyid>,但有 -m <msg> 或 -F <file> 也是新增 annotated tag,隱含 -a 新增沒簽名的 annotated tag。
-f 或 --force 是強制取代已存在相同名子的 tag
--cleanup
列表
指令格式:git tag 或 git tag [-n[<num>]] -l [--contains <commit>] [--points-at <object>] [--column[=<options>] | --no-column] [--create-reflog] [--sort=<key>] [--format=<format>] [--[no-]merged [<commit>]] [<pattern>...](沒有 <tagname> 或含有參數 -l 或 --list)
-n[<num>]:加顯示 tag 的訊息,預設只顯示一行,可指定顯示幾行。
--contains <commit>:只顯示包含特定送交的 tag
--points-at <object>:只顯示特定送交的 tag
--column[=<options>]:column 顯示
--no-column
--create-reflog
--sort=<key>:排序
--format=<format>:顯示格式
--[no-]merged [<commit>]:只列特定送交可到達與否 (待深入了解)
<pattern>:只顯示樣式比對符合的
刪除
(含有參數-d 或 --delete)簽名校驗
(含有參數 -v 或 --verify)tag 修改
以修改 annotated tag 為例:git tag <tagname> <tagname> -a -f自動跳出編輯器修改之前的註釋
git show <tagname>可看到除了原本的註釋,另外有多一筆註釋。如果要覆蓋原本的註釋則用
git tag <tagname> <tagname>^{} -a -f送交修改的 tag
git push <tagname> -f
在別的 git clone 執行 git pull 並不會更新註釋內容,除非知道哪個 tag 有修改,移除它,再 pull
git tag -d <tagname>
git pull
參考及延伸閱讀
- git help tag
- http://stackoverflow.com/questions/7813194/how-do-i-edit-an-existing-tag-message-in-git
- git describe:描述一個送交跟最近可達的 tag 的關係
- git
沒有留言:
張貼留言