How to set version-dependent Git global config flag

To sync all my configuration files, I have a Github repository with all my settings. Although in most cases this works quite well, some applications have different versions on different machines.

So now I'm wondering ... is there a way to set up a global Git configuration such as this (which causes a warning on my laptop) without causing errors on different machines with older versions of Git?

One option would be to wrap a command git pushto add flags with their support, but this seems like a hack.

+3
source share
3 answers

Separate configurations for individual machines

Create different configuration files for different machines and on each machine symbolically link one of them as a real configuration. The symbolic link itself will not be tracked, add it to .gitignore.

Simlingsvyaz can be done in the post-checkouthook . You need to identify the current host (for example uname -n) and have a file that contains the appropriate settings for the hook.

The disadvantage of this solution is that it is not dynamic. When a new version of Git is installed on the host, you should check to see if the appropriate configuration works with it.

What is impossible

-, , , , manpages . Git . , , , .

. , , named pipe, , .

git --version . , Unix, . , , Git .

+1

git script, , . ( repo, .) script push , , git, , .

+1

, , , , 1.7.12+ (, push.default=simple) ~/.config/git/config, gits .

I installed everything that applies to all versions of git in ~/.gitconfig.

0
source

All Articles