Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Git show all branches (but not stashes) in log

I have a Git alias that expands to:

git log --graph --oneline --all --decorate 

According to man git log there are a couple of suspicious options: --not and --branches; but I can't make it work properly.

How should I edit that to hide the stashes?


FYI: as per the accepted question and comment my .gitconfig alias now looks like this:

[alias]     l = log --branches --remotes --tags --graph --oneline --decorate --notes HEAD 
like image 783
cYrus Avatar asked Feb 24 '12 19:02

cYrus


People also ask

Does git log show all branches?

Graph all git branchesDevelopers can see all branches in the graph with the –all switch. Also, in most situations, the –decorate switch will provide all the supplemental information in a formatted and nicely color-coded way.

How do I see all git stashes?

Git Stash List. The Git stash list command will pull up a list of your repository's stashes. Git will display all of your stashes and a corresponding stash index. Now, if you wish to view the contents of a specific stash, you can run the Git stash show command followed by stash@ and the desired index.

Where are git stashes stored?

All are stored in . git/refs/stash . git stash saves stashes indefinitely, and all of them are listed by git stash list . Please note that dropping or clearing the stash will remove it from the stash list, but you might still have unpruned nodes with the right data lying around.


2 Answers

Instead of doing --all and then trying to filter out the stashes, don't ever include them in the first place:

git log --branches --remotes --tags --graph --oneline --decorate 

The main problem that arises from trying to filter them out afterwards is that if the stash is the latest commit on that branch (because even though it's not the head of the branch, it's still the most recent descendant of it), it can actually filter out the entire branch from the log, which isn't what you want.

like image 62
Andrew Marshall Avatar answered Oct 04 '22 10:10

Andrew Marshall


My alias:

[alias]     l = log --oneline --decorate --graph --exclude=refs/stash 

In this case you will be able to use these forms without showing the stash:

  • git l for the current branch
  • git l feature234 for a specific branch
  • git l --all for the overall history

From the manual:

--exclude=<glob pattern>

Do not include refs matching that the next --all, --branches, --tags, --remotes, or --glob would otherwise consider.

like image 31
five Avatar answered Oct 04 '22 11:10

five