5

I am working in a repository that contains hundreds of branches and dozens of active developers.

Yesterday, to resolve an urgent problem, I committed my work to my branch (called feature/new-foo), fixed something in a new branch off master (after git fetch), and went home.

This morning, I forgot what my feature/new-foo branch was called.

I have tried the following:

  • git log --all, which shows all recent commits from all branches, to no avail
  • git branch -v | grep "foo", which searched for all branches with the word foo in it; no good results were found.
  • git for-each-ref --sort=-committerdate refs/heads/, which sorts all branches by commit date; still nothing
  • git stash list, just in case, and my changes weren't there either.

All I remember from my work was the addition of keywords class Edge.

Are there any commands I should try, or is my feature commit forever lost in the sea of branches and commits?


This is not related to: this problem

Community
  • 1
  • 1
Brian
  • 7,394
  • 3
  • 25
  • 46

3 Answers3

6

If you want to use the keywords you added to look for the branch, you could check the commit logs of each branch:

git log --oneline -S "class Edge" --source --all

This will list references of all commits that introduced or removed the string "class Edge".

cmbuckley
  • 40,217
  • 9
  • 77
  • 91
  • I like this! Your code doesn't actually provide the branch name, so I used `git log -S "Edge" --source --all` instead. – Brian Jul 18 '14 at 16:02
  • @Brian that's so much better than mine :-) The `echo {}` part of the xargs job would show the branch name, but using `git log` properly is much better. – cmbuckley Jul 18 '14 at 16:37
4

Assuming that there haven't been a lot of commits, you could run this command to order your branches by last commit. At least then, you can see which branches you've committed to recently to try to figure out which one it might be.

# How can I get a list of git branches, ordered by most recent commit?
# http://stackoverflow.com/q/5188320/165988
git for-each-ref --sort=-committerdate refs/heads/
NT3RP
  • 15,262
  • 9
  • 61
  • 97
0

Try gitk --all and git reflog.

C-Otto
  • 5,615
  • 3
  • 29
  • 62