System settings:
MacOS Catalina 10.15.6
> git --version
git version 2.24.3 (Apple Git-128)
file: ~/.gitconfig
:
[user]
name = nickname
email = [email protected]
[includeIf "gitdir:~/Business"]
path = ~/.gitconfig-work
file: ~/.gitconfig-work
:
[user]
name = First Last
email = [email protected]
Output when trying to check the configuration on terminal:
(base) MBP-Name:~ myname$ cd ~/Business/
(base) MBP-Name:Business myname$ git config --get user.name
nickname
I have tried both relative ~
and absolute /
paths either for gitdir
and path
in the config file. On each change I am restarting the bash. Also, I have read several other stackoverflow questions with no success. Some of them where suggesting adding the i
option for case insensitivity but it didn't fix the problem.
Any ideas ?
I tried removing the double quotes and typing it again. weirdly it worked. since I copied the text from https://blog.gitguardian.com/8-easy-steps-to-set-up-multiple-git-accounts/
I myself also had issues with my .gitconfig. I read the docs a few times, searched Stackoverflow and some blogposts. I though I have tried every possible solution for it: relative paths, trailing slashes, different quotes, et cetera. Non of the solutions I tried actually worked.
I got to the point I just tried to include a file using [include]
, but with no success either.
After a few hours of trying and searching for answers, I came across a post that mentioned a .gitconfig
to be included could also be a .txt
file.
I changed the files from .gitconfig-{company}
to gitconfig-{company}.txt
and renamed the paths in the global .gitconfig
, and everything worked instantly!
I hope this works for you, and future googlers.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With