Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Excluding remote branches from "git log -all"

Tags:

git

Are there ways to list the git log graph from all local branches only?

Consider the command: git log --oneline --graph --decorate --all

Where the "--all" flag would be something like "--localbranchesonly".

like image 290
Luciano Avatar asked Mar 16 '17 14:03

Luciano


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 limit a git log?

The most basic filtering option for git log is to limit the number of commits that are displayed. When you're only interested in the last few commits, this saves you the trouble of viewing all the commits in a page. You can limit git log 's output by including the - option.

What does git log -- all do?

If you want to see the history of all branches/tags/etc., then you can use the --all shortcut. Git log doesn't just show 'the latest commits': it shows all commits that fit the given criteria, of which there are several dimensions. E.g., what branches is the commit on, is the commit in a particular range, etc.

What is git log -- Oneline?

Git Log OnelineThe oneline option is used to display the output as one commit per line. It also shows the output in brief like the first seven characters of the commit SHA and the commit message. It will be used as follows: $ git log --oneline.


2 Answers

--all means "everything in refs/" (plus HEAD as well).

--branches means "everything in refs/heads/".

--remotes means "everything in "refs/remotes/".

--tags means "everything in "refs/tags/".

Except for --all, they all take optional patterns that restrict the match even further.

As Josh Lee mentions, --exclude can be used to limit the matches. There is also --glob, which is like --all in that it applies to all references, but like the others in that it accepts a pattern. Hence --branches=<pattern> essentially means --glob=refs/heads/<pattern>. Note that these are shell style globs, not regular expressions; and metacharacters in them may need to be protected from the shell.

like image 196
torek Avatar answered Oct 27 '22 17:10

torek


git log --branches will show everything under refs/heads, which should limit you to all local branches. Doc for --branches.

You could also do git log --exclude=refs/remotes/* --all, which is more complicated but will give you exactly what you're asking for.

like image 34
Josh Lee Avatar answered Oct 27 '22 17:10

Josh Lee