Wednesday, January 22, 2014

finding source committed to the wrong Git branch, or, CLI FTW

The other day I added a "test_epoll" file, but now I've lost the branch that contained it.  I have 15 branches locally -- how do I find the file?

Here's one way: for all branches not checked out, show the differences between it and the current branch, specifically looking for files which contain the word "poll".  For each branch, "trace" (echo) the command first, before listing the files different from current branch.


$ git branch | egrep -v '\*' | xargs -t -n1 git diff --stat | egrep poll

git diff --stat feature/ent958
eimport/epollmail.py | 244 ++
eimport/tests/test_epollmail.py | 149 ++
scripts/epollmail | 18 +

Ah -- my stuff was found in branch ent958. Thanks, command line!

No comments:

Post a Comment