Skip to content

Instantly share code, notes, and snippets.

@lifuzu
Created March 11, 2014 17:09
Show Gist options
  • Save lifuzu/9490352 to your computer and use it in GitHub Desktop.
Save lifuzu/9490352 to your computer and use it in GitHub Desktop.
Three levels of GIT config
# There are 3 levels of git config; project, global and system.
# project: Project configs are only available for the current project and stored in .git/config in the project's directory.
# global: Global configs are available for all projects for the current user and stored in ~/.gitconfig.
# system: System configs are available for all the users/projects and stored in /etc/gitconfig.
# Create a project specific config, you have to execute this under the project's directory.
$ git config user.name "John Doe"
# Create a global config
$ git config --global user.name "John Doe"
# Create a system config
$ git config --system user.name "John Doe"
@SaifFGit
Copy link

SaifFGit commented Jun 4, 2022

Thanks!

@FrancoisHub
Copy link

FrancoisHub commented Aug 21, 2023

For helping Windows users:

  • project: Project configs are only available for the current project and stored in .git/config in the project's directory.
  • global: Global configs are available for all projects for the current user and stored in the user's folder: C:/Users//.gitconfig.
  • system: System configs are available for all the users/projects and stored where Git is installed which is by default C:/Program Files/Git/etc/gitconfig.

@patacra
Copy link

patacra commented Mar 11, 2025

There is also the worktree level : See git-config documentation about this level

I know this case is rather rare, but typically on some big projects, where you need to have several releases of your code on your hard drive, at the same time, worktrees are very helpful. You only have the .git repository once on the drive, but you can have several branches open at the same time.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment