簡體   English   中英

Git:查找所有標簽,可從提交訪問

[英]Git: find all tags, reachable from a commit

如何列出可從給定提交訪問的所有標簽

對於所有分支,它是git branch --all --merged <commit> 對於最近的標簽,它是git describe

手冊頁git-tag建議git tag -l --contains <commit> * ,但此命令不顯示我知道可以訪問的任何標簽。

使用此腳本打印出給定分支中的所有標記

git log --decorate=full --simplify-by-decoration --pretty=oneline HEAD | \
sed -r -e 's#^[^\(]*\(([^\)]*)\).*$#\1#' \
-e 's#,#\n#g' | \
grep 'tag:' | \
sed -r -e 's#[[:space:]]*tag:[[:space:]]*##'

該腳本只是一條長線,分解為適合后窗口。

說明:
 git log // Print out the full ref name --decorate=full // Select all the commits that are referred by some branch or tag // // Basically its the data you are looking for // --simplify-by-decoration // print each commit as single line --pretty=oneline // start from the current commit HEAD // The rest of the script are unix command to print the results in a nice // way, extracting the tag from the output line generated by the // --decorate=full flag. 

手冊頁 git-tag 建議使用 git tag -l --contains *,但此命令不顯示我知道可以訪問的任何標簽。

git tag --contains用於相反的搜索。 它顯示包含給定提交的所有標簽。 (這與git branch --contains行為相同。)

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM