DEV Community

Alish Giri
Alish Giri

Posted on

You don't have to memorize get config commands!

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
Enter fullscreen mode Exit fullscreen mode

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
Enter fullscreen mode Exit fullscreen mode
nano .git/config
Enter fullscreen mode Exit fullscreen mode
open .git/config -a <your_IDE>
Enter fullscreen mode Exit fullscreen mode

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
Enter fullscreen mode Exit fullscreen mode

Billboard image

The Next Generation Developer Platform

Coherence is the first Platform-as-a-Service you can control. Unlike "black-box" platforms that are opinionated about the infra you can deploy, Coherence is powered by CNC, the open-source IaC framework, which offers limitless customization.

Learn more

Top comments (0)

Image of Docusign

🛠️ Bring your solution into Docusign. Reach over 1.6M customers.

Docusign is now extensible. Overcome challenges with disconnected products and inaccessible data by bringing your solutions into Docusign and publishing to 1.6M customers in the App Center.

Learn more