October 27th 2017
When working in a team environment, it's very useful to be able to share Git configuration across team members.
One way of achieving this is to add a
.gitconfig file to the root of your project repository.
Within this file you can set up Git configuration, for example if you wish to share common Git aliases across your team you can use the following:
[alias]s = status -slg = log --oneline --decorate --graph --all -20pb = !sh -c 'git branch --merged | grep -v "^*" | xargs git branch -d'
Here, we're setting up the following aliases:
s- display short working tree status
lg- display graph version of the commit logs
pb- prune all merged local branches
Next, each team member can perform a one off update per repository of their Git configuration file at
.git\config, adding the following to the end of the file:
[include]path = ../.gitconfig
The path to the
.gitconfig file is relative to the
.git\config file. Here, we're assuming the
.gitconfig file is a sibling to your
.git folder - i.e. in the root of your repository.