开发者

restore lost commit by a known folder name

I have lost a branch accidentally. I guess it is in reflog list, but it's too difficult to check every one in it. I remember that there was a folder created in that branch with some files in it, so it sho开发者_JAVA技巧uld be possible to find my branch by finding all the lost commits that affects the folder. So the question is: how can I find these commits?


I should just specify the path in the reflog command. It's important to use '--' before the path if it is absent in working tree

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


You can grep the output of git lstree to find about the commits in a branch:

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
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜