How to set important Git configuration global properties
There are many ways to customize a development environment, but the global Git configuration file is one that is most likely to be used for custom settings such as usernames, emails, preferred text editors, and remote branches. Here are the key things you need to know about global Git configuration files.
Where is the global git configuration file located?
The global Git configuration file is stored in a home directory called .gitconfig user. Depending on the operating system, this will be:
- C:Users on Windows
- ~home/Linux
- ~root/ for sudo operation
One thing to note is that each user has his own global Git configuration file. This can cause problems if you run a shell script using the sudo command. If you use sudo in your script, the ~root/.gitconfig file will be used instead of the global git configuration file of the user running the script. This can lead to unexpected results, so use the sudo command with caution.

The git config –list command will display global git configuration settings.
Git configures global username and email
Before issuing a local Git submission, you must set the global git configuration username and email properties. Don't worry, your name and email won't appear on the mailing list. These details are used only as metadata in each commit, so anyone who looks at the Git logs will know who submitted the code and how to contact them. There is nothing evil about the global username and email requirements configured by Git.
How to set global git configuration settings?
There are several ways to edit a global git configuration file. One way is to add properties via the command line. Global git configuration email and username properties are usually set as follows:
git config --global user.name cameraonmcnz git config --global user.email global-config@example.com
For more expressiveness, you can include the –add switch when setting the global git configuration properties:
git config --global --add user.name cameraonmcnz git config --global --add user.email global-config@example.com
How to perform git config global editing?
The global git configuration is just a text file, so it can be edited using any text editor of your choice. Open, edit the global git configuration, save and close, and the changes will take effect the next time the git command is issued. It's that simple.
From a BASH shell or terminal window, you can call the default Git editor with the following command:
git config --global --edit
On Ubuntu, this will open the Nano text editor, which I don't really like. Fortunately, the global git configuration file can be used to change the default Git editor to what you think is more user-friendly.
Configure Git global core editor
The following commands can be used to change the default text editor for global Git configuration to Vim, emacs, Textmate, or Atom. There is a separate tutorial on how to make the core editor for NotePad Git, which is easy to do on Windows, but a little hard to predict on Linux.
Global Git Config Core Editor Settings | |
---|---|
Text Editor | Global Git Config Command |
Atom | git config –global core.editor “atom –wait” |
emacs | git config –global core.editor “emacs” |
Textmate | git config –global core.editor “mate -w” |
vim | git config –global core.editor “vim” |
How to override Git global configuration?
Git uses the gitconfig file's cascading application to determine the value of the Git configuration properties used at runtime. Here are five common Git configuration ranges, from the most specific to the most general:
- workingtree
- local
- Global
- system
- portable
Since the working tree and local git scope are more specific than global, any variables set in these files will override the git config global scope. So if you need a specific Git configuration username or email for a given repository, or a special setting for the Git work tree you want to add, you can use local or work tree scopes.
List and display global git configuration
To view all properties of the global configuration in Git, you can use the --list switch on the git config command. Adding the --show-origin switch will also tell you where the global .gitconfig file is located.
global@git:~/$ git config --global --list --show-originfile:/home/gme/.gitconfig user.email=cameronmcnz@example.comfile:/home/gme/.gitconfig user.name=cameronmcnzfile:/home/gme/.gitconfig core.editor=vimfile:/home/gme/.gitconfig http.sslverify=falsefile:/home/gme/.gitconfig credential.helper=storefile:/home/gme/.gitconfig http.proxy=193.168.0.11file:/home/gme/.gitconfig http.postbuffer=193.168.0.12file:/home/gme/.gitconfig http.sslcainfo=193.168.0.10
Delete global git configuration settings
To remove the git configuration settings, simply use the unset command:
git config --global --unset core.editor
Sometimes, a property is set twice and the –unset switch fails. In this case, just use the --unset-all switch of the global git config.
git config --global --unset-all core.editor
Global git configuration is an important file for custom version control experience. It is important to know how to display Git configuration settings, and it is also important to be able to edit, update, and delete settings. Knowing how to do it will surely make your experience with the global Git configuration tool even more enjoyable.
The above is the detailed content of How to set important Git configuration global properties. For more information, please follow other related articles on the PHP Chinese website!

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics

The five basic components of the Linux system are: 1. Kernel, 2. System library, 3. System utilities, 4. Graphical user interface, 5. Applications. The kernel manages hardware resources, the system library provides precompiled functions, system utilities are used for system management, the GUI provides visual interaction, and applications use these components to implement functions.

To install Laravel, follow these steps in sequence: Install Composer (for macOS/Linux and Windows) Install Laravel Installer Create a new project Start Service Access Application (URL: http://127.0.0.1:8000) Set up the database connection (if required)

Analysis of memory leak phenomenon of Java programs on different architecture CPUs. This article will discuss a case where a Java program exhibits different memory behaviors on ARM and x86 architecture CPUs...

How to set the SpringBoot project default run configuration list in Idea using IntelliJ...

About SpringCloudAlibaba microservices modular development using SpringCloud...

I encountered a tricky problem when developing a multi-device-compatible website: how to accurately identify the user's browser and device information. After trying multiple methods, I found that directly parsing user-agent strings (User-Agent) are both complex and unreliable, and often misjudgments occur. Fortunately, I successfully solved this problem by installing the WhichBrowser/Parser library using Composer.

Version control is a key link when managing PHP projects. Recently I was working on a Git-based PHP project and I encountered a problem: how to automatically generate and manage version numbers during development. This problem seems simple, but manual maintenance of the version number is not only cumbersome, but also prone to errors. After some exploration, I found a very useful tool - the sebastian/version library, which was easily integrated into the project through Composer, completely solving my troubles.

Efficient programming: Looking for reliable code tools and resources Many programmers are eager to find convenient code tools websites to improve efficiency and avoid massive information...
