2010-11-18 79 views
3

我意外丢失了一个分支。我想这是在reflog列表中,但是很难检查其中的每一个。我记得在该分支中创建了一个文件夹,其中包含一些文件,因此应该可以通过查找影响该文件夹的所有丢失的提交来查找我的分支。所以问题是:我怎么能找到这些提交?通过已知文件夹名称恢复丢失提交

回答

2

我应该只指定在引用日志命令的路径。在路径前使用“ - ”(如果它在工作树中不存在),使用' - '很重要

git reflog -- path/to/the/affected/folder 
+0

请注意,它显示与'git log -g path/to/it'相同的信息。 – 2010-11-18 18:41:11

0

您可以grep的git lstree输出,以找到一个分支的提交:

for ID in `git reflog | cut -d' ' -f1` # filter out the commit ID 
do 
    # show the tree for each commit and grep for the file there 
    git ls-tree -r $ID | grep file/name && echo "File is on $ID" 
done