If you modify git configuration more that an average developer then the simplest way to edit git configuration is by opening up the file and modifying the contents directly.
This is super useful if you have two different GitHub accounts, one personal and the other for work. Where you have to update the config file to adjust the signing key, adding suffix to the origin url, along with other informations. This approach mentioned here can save you valuable time if you have a habit like mine to forget the git commands frequently 😄.
You can use the following command to locate your global git config file.
git config --list --show-origin
However, most of the time we want primary account to be the global config and for secondary account we want to have a project based configuration file.
For your current project
.git/config
is where the config file is stored and this file is a copy of global git config file.
Now, use one of the following command to open up a file and then modify the contents directly.
vim .git/config
nano .git/config
open .git/config -a <your_IDE>
This way you do not have to memorize all sorts of git commands.
SAMPLE CONFIG FILE
[core]
repositoryformatversion = 0
filemode = true
bare = false
logallrefupdates = true
ignorecase = true
precomposeunicode = true
[remote "origin"]
url = <your_origin>
fetch = +refs/heads/*:refs/remotes/origin/*
[user]
name = <username>
email = <your_email>
signingkey = XXXXXXXXXXXXXXXX
[commit]
gpgsign=true
[branch "prod"]
remote = origin
merge = refs/heads/prod
vscode-merge-base = origin/prod
[branch "dev"]
vscode-merge-base = origin/main
remote = origin
merge = refs/heads/dev
[lfs]
repositoryformatversion = 0
Top comments (0)