找到一个包含对给定文件的更改的Git分支 [英] Find a Git branch containing changes to a given file

查看:104
本文介绍了找到一个包含对给定文件的更改的Git分支的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有57个地方分支机构。我知道我在其中一个文件中对某个文件进行了更改,但我不确定哪一个文件。是否有某种命令可以运行,以查找哪些分支包含对某个文件的更改? 解决方案

改变为FILENAME(即使在(未记录的)分支点之前)

  FILENAME =< filename> 
git log --all --format =%H $ FILENAME |同时读f;做git分支 - 包含$ f;完成| sort -u

手动检查:

  gitk --all --date-order  -  $ FILENAME 

查找所有对未合并到主文件中的FILENAME的更改:

  git for-each-ref --format =%(refname:短)refs / head | grep -v master |同时阅读br;做git樱桃大师同时阅读x h;如果[`git log -n 1 --format =%H $ h  -  $ FILENAME`=$ h];然后echo $ br;网络连接;完成;完成| sort -u 


I have 57 local branches. I know I made a change to a certain file in one of them, but I'm not sure which one. Is there some kind of command I can run to find which branches contain changes to a certain file?

解决方案

Find all branches which contain a change to FILENAME (even if before the (non-recorded) branch point)

FILENAME="<filename>"
git log --all --format=%H $FILENAME | while read f; do git branch --contains $f; done | sort -u

Manually inspect:

gitk --all --date-order -- $FILENAME

Find all changes to FILENAME not merged to master:

git for-each-ref --format="%(refname:short)" refs/heads | grep -v master | while read br; do git cherry master $br | while read x h; do if [ "`git log -n 1 --format=%H $h -- $FILENAME`" = "$h" ]; then echo $br; fi; done; done | sort -u

这篇关于找到一个包含对给定文件的更改的Git分支的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆