- Trending Categories
- Data Structure
- Operating System
- MS Excel
- C Programming
- Social Studies
- Fashion Studies
- Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
How to change the default configuration in Git?
The default configuration should be modified when you use Git for the first time. The git config command can be used to achieve the same. The following are some Git configuration settings that can be set −
Git allows us to configure the above settings at different levels. This means we can have different settings for different repositories of different projects. All configurations are stored in a configuration file.
The syntax to modify Git’s configuration is −
git config <config_level> configuration_name [additional_flags]
Git configuration can be modified at the following levels −
System − System−level configuration is applied across an entire machine and covers all users on the machine and all repos. The system-level configuration file can be found in a gitconfig file off the system root path. On Unix systems, this is “$(prefix)/etc/gitconfig”. On Windows, this file can be found at “C:\Documents and Settings\All Users\Application Data\Git\config” on Windows XP and in “C:\ProgramData\Git\config” on Windows Vista and newer.
Global − Global configuration is user-specific and is applied to all repositories of the current user. Global configuration values are stored in a file that is located in a user's home directory. This is “~/.gitconfig” on Unix systems and “C:\Users\.gitconfig” on Windows.
Local − Local configuration is applied only to the current repository. By default, the “.gitconfig” file will write to a local level if no configuration option is passed. Local configuration values are stored in a file that can be found under “.git/config”
The order of priority for configuration levels is: local, global, system.
You can use the following commands to configure various Git settings locally −
$ git config -help $ git config --local user.name “Kiran Panigrahi” $ git config --local user.email firstname.lastname@example.org
The following command sets Visual Studio Code as the local editor −
$ git config −−local core.editor “code −−wait”
Note that the PATH environment variable is set to the desired editor (here Visual Studio Code). The wait flag instructs the terminal window to wait until we close the editor which is opened.
The configuration file can be opened for editing using −e flag with the git config command.
$ git config −−local −e
The above command opens the configuration file in Visual Studio Code editor. It is clear from the following screenshot that the configuration added earlier are recorded.
Kickstart Your Career
Get certified by completing the courseGet Started