michael
michael

Reputation: 110510

Find out the my recent use branches in git

Is there a way to find out what are the last 5 branches that I most recently used (i.e. git checkout -b )? I am looking for a commit that I did, but I forget which branch I check that commit into.

Upvotes: 0

Views: 59

Answers (3)

Makoto
Makoto

Reputation: 106389

You can filter commits by a specific committer through git-log:

git log --graph --oneline --author="<your Git name here>" --decorate --all

I personally use --oneline --decorate so that I can:

  • see which branch it's on
  • only see the SHA

I mention this solution because you're less concerned with the last five branches you worked on, and you're more concerned with the actual branch you made that commit on.

Upvotes: 0

Mohammad AbuShady
Mohammad AbuShady

Reputation: 42789

To show all logs from all branches, you could add a --all flag to git log

git log --all

If you know the message you used in the commit you could add a --grep with a word you used

git log --all --grep blah

If you know what file the commit touched, you could add that file after a -- separator

git log --all -- /path/to/file

All these methods will list the commits that matches them, should be easy to find the commit if it's recent, if the commit became dangling ( not currently inside any branch ) you'll need to use either git-reflog or git-fsck

Upvotes: 1

michas
michas

Reputation: 26495

Have a look at git reflog. It will show you everything you have done lately.

Upvotes: 1

Related Questions