splitting the config

Gitconfig is a interesting file when you are able to use an if statement based on the directory of a project. Below is my tree for projects that both define personal and professional configurations. This allows me

├── .sh.d
├── src
│   ├──
│   └──
├── .gitconfig
├── .gitconfig-personal
├── .gitconfig-work

In my $HOME/.gitconfig file I have the following:

[includeIf "gitdir:~/src/"]
	path = .gitconfig-personal
[includeIf "gitdir:~/src/"]
	path = .gitconfig-work

Then in my $HOME/.gitconfig-personal, I use the following content:

name = Aaron Addleman
email = [email protected]
signingkey = FCF6C3A2140015F9

gpgSign = true

The other file of $HOME/.gitconfig-work shares the same name, but a different email address. This helps automatically set the Name and Email settings for git projects based on the top level directory they reside within.


Sometimes its needed to have some handy aliases to do git actions. Two of them I have been using is the reset from origin and reset from upstream:

resetorigin = !git fetch origin && git reset --hard origin/${1-main} && git clean -f -d
resetupstream = !git fetch upstream && git reset --hard upstream/${1-main} && git clean -f -d