- Trending Categories
- Data Structure
- Operating System
- C Programming
- 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.
- How to change the default charset of a MySQL table?
- How can we change the default MySQL database to the given database?
- Who to Change the Default Display Value using CSS
- How to change default point size of geom_point in R?
- How do I change the Tkinter default title in the OS bar?
- How to change the default path for "save the figure" in Matplotlib?
- Change tinyint default value to 1 in MySQL?
- Change the default background color for Matplotlib plots
- Change the default capacity of the StringBuffer Object in Java
- How can we change the default font of the JTabbedPane tabs in Java?
- How can I change the default sort order of MySQL tables?
- How to change the default type of points for scatterplot using ggplot2 in R?
- How to check the current configuration of MongoDB?
- Change the default location for saving sketches in Arduino IDE
- How do you change the default font color for all text in Matplotlib?