Table of Contents
Motivation
Working on different projects with different user info and settings you may find it necessary to dive deeper into the git configuration.
First of all you need to know that there are at least three git configuration files
- system
- global
- local
- worktree
Each level overrides values in the previous level, so local overwrites global, global overwrites system config.
File path
The following tables shows the paths to the config files:
Level | Path on Windows | Path on macOS |
---|---|---|
System | C:\Program Files\Git\etc\gitconfig | /usr/local/git/etc/gitconfig |
Global | C:\Users\<user_name>\.gitconfig | $HOME/.gitconfig |
Local | e.g. C:\Users\<user_name>\PycharmProjects\<project_name>\.git\config | e.g /Users/<user_name>/PycharmProjects/python_katas/.git/config |
Configuring the User
[user] name = jboegeholz email = boegeholz.joern@gmail.com
Useful commands
Check user
To check if your configuration is complete / correct you can use:
git config user.name
git config --list
Set github Personal Acess Token
git remote set-url origin https://<token>@github.com/<username>/<repository>.git