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

打不死的小强
原文地址:https://www.cnblogs.com/mggahui/p/15102056.html