threads / discuss / 59151

Feature Request - GIT config - Reference value of init.defaultBranch in alias

Subject: Feature Request - GIT config - Reference value of init.defaultBranch in alias

## tl;dr

2 messages between Jan 26, 2023 and Jan 26, 2023.

replies: 1people: 2as markdown or json

Michal Aron· Jan 26, 2023, 09:33 UTC · lore
Hello,
I am curious why it is not possible to reference other variables in git config.
Useful scenario:

Global git config containing all useful aliases which often reference the default main branch. I discovered the config variable init.defaultBranch and I would like to reference it in the aliases.

1) global config having init.defaultBranch = master
2) global config having alias com = checkout [ init.defaultBranch ]
3) local repos replacing this value e.g. to init.defaultBranch = main
4) using this alias in local repo git com, which will checkout me to
the init.defaultBranch of this repository..

This would allow us to use global aliases independently on the repositories.. If this has not yet been discussed I believe it is the time since many repositories are being customized to the company team/company culture.

Appreciate and thanks, Michal
Junio C Hamano· Jan 26, 2023, 16:21 UTC · re: Michal Aron · lore

Re: Feature Request - GIT config - Reference value of init.defaultBranch in alias

Michal Aron <aronmgv@gmail.com> writes:
> 1) global config having init.defaultBranch = master
> 2) global config having alias com = checkout [ init.defaultBranch ]

I do not think it is a good idea to special case just a single configuration variable and come up with a special syntax to refer to it.

Isn't
  [alias]
	com = !git checkout $(git config init.defaultBranch)
sufficient?

← back to recent threads