git查看哪些分支包含了哪些文件內容


需求

查看哪些分支包含了對應文本內容。

1,當印象中只知道代碼的部分內容,但是卻找不到代碼文件的時候(往往代碼不在當前分支或者存在於歷史記錄中),此方法有效

根據內容查找git文件並顯示commitid

git grep "toQuestionList" $(git rev-list --all)

查找git倉庫文件中中包含字符串"toQuestionList",顯示結果如下

查看commitid屬於哪個分支 

git branch --contains 4369d46d0c31641d1f994b4e90c9ea380f0eecf1 --all

 其中紅色部分內容表示查詢到的分支名稱

獲取最新鮮的分支

git for-each-ref --sort=committerdate refs/heads/ --format='%(HEAD) %(color:yellow)%(refname:short)%(color:reset) - %(color:red)%(objectname:short)%(color:reset) - %(contents:subject) - %(authorname) (%(color:green)%(committerdate:relative)%(color:reset))'

 

 

 

參考鏈接

https://www.it1352.com/2100400.html

https://blog.csdn.net/yang1349day/article/details/112171438


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM