Skip to contentSkip to conversation

git log alias with --all and --exclude

DISCUSSION Rene Kita 4 participants 6 messages Sep 4, 2024 – Sep 5, 2024

lore
Share & tools
lore

Rene Kita

author
#0 lore raw

I have an alias
'gr = log --oneline --abbrev-commit --all --graph --decorate --color' and I would like to be able to sometimes exclude a branch, so call it with:

$ git gr --exclude=pattern

This does not work, though. Also does not work without the alias and typing the complete command by hand. Apparently the --exclude must be put before the --all to take effect.

May I ask to change that behavior and allow to put the --exclude at the end of the alias?

Rene

#1 lore raw

Am 04.09.24 um 11:06 schrieb Rene Kita:

Quoted 9 lines

I have an alias
'gr = log --oneline --abbrev-commit --all --graph --decorate --color' and I would like to be able to sometimes exclude a branch, so call it with:

$ git gr --exclude=pattern

This does not work, though. Also does not work without the alias and typing the complete command by hand. Apparently the --exclude must be put before the --all to take effect.

That is very much by design, so that you can express "branches except the wip and preview branches and remotes except those from the remote archive" with

--exclude=wip/* --exclude=preview* --branches --exclude=archive/* --remotes

These collective branch options --branches, --remotes, and --all clear the exclude patterns after having them applied. Therefore, in this example, the first two --exclude do not affect --remotes.

-- Hannes

author
#2 lore raw
Quoted 15 lines · Johannes Sixt

Am 04.09.24 um 11:06 schrieb Rene Kita:

Quoted 9 lines

I have an alias
'gr = log --oneline --abbrev-commit --all --graph --decorate --color' and I would like to be able to sometimes exclude a branch, so call it with:

$ git gr --exclude=pattern

This does not work, though. Also does not work without the alias and typing the complete command by hand. Apparently the --exclude must be put before the --all to take effect.

That is very much by design, so that you can express "branches except the wip and preview branches and remotes except those from the remote archive" with

Quoted 5 lines

--exclude=wip/* --exclude=preview* --branches --exclude=archive/* --remotes

These collective branch options --branches, --remotes, and --all clear the exclude patterns after having them applied. Therefore, in this example, the first two --exclude do not affect --remotes.

OK, certainly not the answer I hoped for, but something I still expected. Thanks for the explanation.

Quoted 2 lines

-- Hannes

#3 lore raw
Quoted 17 lines · Rene Kita
Quoted 15 lines · Johannes Sixt

Am 04.09.24 um 11:06 schrieb Rene Kita:

Quoted 9 lines

I have an alias
'gr = log --oneline --abbrev-commit --all --graph --decorate --color' and I would like to be able to sometimes exclude a branch, so call it with:

$ git gr --exclude=pattern

This does not work, though. Also does not work without the alias and typing the complete command by hand. Apparently the --exclude must be put before the --all to take effect.

That is very much by design, so that you can express "branches except the wip and preview branches and remotes except those from the remote archive" with

Quoted 9 lines
Quoted 5 lines

--exclude=wip/* --exclude=preview* --branches --exclude=archive/* --remotes

These collective branch options --branches, --remotes, and --all clear the exclude patterns after having them applied. Therefore, in this example, the first two --exclude do not affect --remotes.

OK, certainly not the answer I hoped for, but something I still expected. Thanks for the explanation.

You could implement this as a shell alias so that your options get included before the --all. I'm not sure how trivial that would be to do, but thats how I would go about implementing this alias.

#4 lore raw
Quoted 5 lines · Jacob Keller
Quoted 1 line
Quoted 1 line
Quoted 1 line

'gr = log --oneline --abbrev-commit --all --graph --decorate --color'

You could implement this as a shell alias so that your options get included before the --all. I'm not sure how trivial that would be to do, but thats how I would go about implementing this alias.

True. If I were doing this, I would at least do something like

    [alias]
	rg = "!sh -c 'git log --oneline --abbrev-commit --graph \
		--decorate --color ${1-\"--all\"} \"$@\"' -"

so that

(1) "git rg" without any argument will default to "--all"
(2) "git rg --exclude 'wip*' --branches" would work as expected, just like "git rg --first-parent master..seen" would.

Thanks.

author
#5 lore raw
Quoted 14 lines · Junio C Hamano
Quoted 5 lines · Jacob Keller
Quoted 1 line
Quoted 1 line
Quoted 1 line

'gr = log --oneline --abbrev-commit --all --graph --decorate --color'

You could implement this as a shell alias so that your options get included before the --all. I'm not sure how trivial that would be to do, but thats how I would go about implementing this alias.

True. If I were doing this, I would at least do something like

    [alias]
	rg = "!sh -c 'git log --oneline --abbrev-commit --graph \
		--decorate --color ${1-\"--all\"} \"$@\"' -"
Quoted 7 lines

so that

(1) "git rg" without any argument will default to "--all"
(2) "git rg --exclude 'wip*' --branches" would work as expected, just like "git rg --first-parent master..seen" would.

Thanks.

Thanks for the ideas, I will adjust my alias.