2015-12-17 10:09:03 +00:00
|
|
|
# git config
|
|
|
|
|
2021-01-07 14:06:38 +00:00
|
|
|
> Manage custom configuration options for Git repositories.
|
2017-06-15 23:30:21 +01:00
|
|
|
> These configurations can be local (for the current repository) or global (for the current user).
|
2019-06-03 01:06:36 +01:00
|
|
|
> More information: <https://git-scm.com/docs/git-config>.
|
2015-12-17 10:09:03 +00:00
|
|
|
|
2024-08-10 15:38:48 +01:00
|
|
|
- Globally set your name or email (this information is required to commit to a repository and will be included in all commits):
|
2015-12-17 10:09:03 +00:00
|
|
|
|
2024-08-10 15:38:48 +01:00
|
|
|
`git config --global {{user.name|user.email}} "{{Your Name|email@example.com}}"`
|
2015-12-17 10:09:03 +00:00
|
|
|
|
2024-08-10 15:38:48 +01:00
|
|
|
- List local or global configuration entries:
|
2015-12-17 10:09:03 +00:00
|
|
|
|
2024-08-10 15:38:48 +01:00
|
|
|
`git config --list --{{local|global}}`
|
2015-12-17 10:09:03 +00:00
|
|
|
|
2022-08-16 03:04:51 +01:00
|
|
|
- List only system configuration entries (stored in `/etc/gitconfig`), and show their file location:
|
2015-12-17 10:09:03 +00:00
|
|
|
|
2022-08-16 03:04:51 +01:00
|
|
|
`git config --list --system --show-origin`
|
2015-12-17 10:09:03 +00:00
|
|
|
|
2017-06-15 23:30:21 +01:00
|
|
|
- Get the value of a given configuration entry:
|
2015-12-17 10:09:03 +00:00
|
|
|
|
2017-06-15 23:30:21 +01:00
|
|
|
`git config alias.unstage`
|
2015-12-17 10:09:03 +00:00
|
|
|
|
2017-06-15 23:30:21 +01:00
|
|
|
- Set the global value of a given configuration entry:
|
2015-12-17 10:09:03 +00:00
|
|
|
|
2017-06-15 23:30:21 +01:00
|
|
|
`git config --global alias.unstage "reset HEAD --"`
|
2015-12-17 10:09:03 +00:00
|
|
|
|
2017-06-15 23:30:21 +01:00
|
|
|
- Revert a global configuration entry to its default value:
|
2015-12-17 10:09:03 +00:00
|
|
|
|
2017-06-15 23:30:21 +01:00
|
|
|
`git config --global --unset alias.unstage`
|
2020-07-17 18:40:48 +01:00
|
|
|
|
2024-08-10 15:38:48 +01:00
|
|
|
- Edit the local Git configuration (`.git/config`) in the default editor:
|
2020-07-17 18:40:48 +01:00
|
|
|
|
|
|
|
`git config --edit`
|
|
|
|
|
2024-08-10 15:38:48 +01:00
|
|
|
- Edit the global Git configuration (`~/.gitconfig` by default or `$XDG_CONFIG_HOME/git/config` if such a file exists) in the default editor:
|
2020-07-17 18:40:48 +01:00
|
|
|
|
|
|
|
`git config --global --edit`
|