我如何搜索Git分支文件或目录? [英] How can I search Git branches for a file or directory?

查看:140
本文介绍了我如何搜索Git分支文件或目录?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在Git中,我怎么能通过多个分支的路径搜索文件或目录?



我在分支中写了一些东西,但我不知道不记得哪一个。现在我需要找到它。



澄清:我正在寻找一个我在其中一个分支上创建的文件。我希望能够通过路径找到它,而不是其内容,因为我不记得内容是什么。 解决方案

p> git log会为你找到它:

 %git log --all  -  somefile 

commit 55d2069a092e07c56a6b4d321509ba7620664c63
作者:Dustin Sallings< dustin@spy.net>
日期:星期二十二月十六日14:16:22 2008 -0800

添加somefile
%git分支-a - 包含55d2069
其他分支

支持globbing:

 %git log --all  - '** / my_file.png'

单引号是必要的(至少如果使用bash shell),所以shell将glob模式传递给git,而不是扩展它(就像使用Unix find )。 p>

In Git, how could I search for a file or directory by path across a number of branches?

I've written something in a branch, but I don't remember which one. Now I need to find it.

Clarification: I'm looking for a file which I created on one of my branches. I'd like to find it by path, and not by its contents, as I don't remember what the contents are.

解决方案

git log will find it for you:

% git log --all -- somefile

commit 55d2069a092e07c56a6b4d321509ba7620664c63
Author: Dustin Sallings <dustin@spy.net>
Date:   Tue Dec 16 14:16:22 2008 -0800

    added somefile
% git branch -a --contains 55d2069
  otherbranch

Supports globbing, too:

% git log --all -- '**/my_file.png'

The single quotes are necessary (at least if using the bash shell) so the shell passes the glob pattern to git unchanged, instead of expanding it (just like with Unix find).

这篇关于我如何搜索Git分支文件或目录?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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