Git local configuration file variables

I have a set of aliases for different types of logs, for example:

lg = log --graph --pretty=format:'%C(cyan)%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr) %C(red)<%an>%Creset' --abbrev-commit --date=relative
unreleased = !git --no-pager log --graph --pretty=format:'%C(cyan)%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr) %C(red)<%an>%Creset' --abbrev-commit --date=relative release..master

There are many types of journal aliases, but most of them have the same format. How to define a local variable with the contents of the common parts?

Ideally, I would like to avoid using an environment variable for this

+4
source share
1 answer

Like this question , git-config does not support variable expansion, however you can define an alias with common parts:

lg = log --graph --pretty=format:'%C(cyan)%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr) %C(red)<%an>%Creset' --abbrev-commit --date=relative

Then define additional aliases as shell commands that use a common alias:

unreleased = !git --no-pager lg release..master

, --date=relative , %cr . , --date=short, , . %cd , , .

+3

Source: https://habr.com/ru/post/1532806/


All Articles