www.theserverside.com Open in urlscan Pro
2606:4700:4400::6812:29a3  Public Scan

URL: https://www.theserverside.com/blog/Coffee-Talk-Java-News-Stories-and-Opinions/Where-system-global-and-local-Windows-Git-config...
Submission: On July 03 via api from AO — Scanned from DE

Form analysis 1 forms found in the DOM

GET https://www.theserverside.com/search/query

<form action="https://www.theserverside.com/search/query" method="get" class="header-search">
  <label for="header-search-input" class="visuallyhidden">Search the TechTarget Network</label>
  <input class="header-search-input tss ui-autocomplete-input" id="header-search-input" type="text" name="q" placeholder="Search the TechTarget Network">
  <button aria-label="Search" class="header-search-submit"><i class="icon" data-icon="g"></i></button>
</form>

Text Content

Search the TechTarget Network
Sign-up now. Start my free, unlimited access.
Login Register
 * White Papers
 * Definitions
 * Java DevOps
 * Webinars

RSS
 * Topic Java tools
    * Enterprise Java development
    * Java in the cloud
    * Java management
    * Mobile app dev
    * Modular code
    * Architecture
    * Web dev tools
    * All Topics

 * SubTopic All Subtopics
    * Java performance
    * Java HPC
    * Cloud platforms
    * Java performance
    * JVM tuning
    * All Subtopics

 * Follow:
 * 
 * 


ESSENTIAL GUIDE

Browse Sections
 * Getting started with Git
   * IT pros weigh Git version control against the competition
   * Step-by-step guide: How to install Git on Windows desktop computers
   * 5 basic Git commands developers must master: Tutorial with examples
   * How not to write a Git commit message
   * How to set Notepad++ as the default Git editor for commits instead of Vim
 * Git and Github
   * Git vs. GitHub: What is the difference between them?
   * Microsoft-GitHub acquisition shakes up DevOps market
   * Want a private GitHub repository? It comes with a catch
   * How to Git started and use the Github Desktop app tool
   * Tough sample GitHub interview questions and answers for job candidates
 * Fix bad mistakes with Git
   * How to revert a Git commit: A simple undo changes example
   * A Git reset hard example: An easy way to undo local commits and shift head
   * Don't Git revert that last commit, Git reset instead
   * Learn to Git cherry-pick a commit with this easy example
   * How to 'Git cherry-pick' from another branch to your own
 * Git integration with Jenkins
   * Jenkins Git integration: GitHub pull request via the Git plugin
   * How to use the Jenkins Git Plugin: Tips and tricks
   * Jenkins Git environment variables list: A working shell script example
   * Use the Jenkins OAuth plug-in to securely pull from GitHub
   * Tough sample GitHub interview questions and answers for job candidates
 * Where Git fits in your distributed version control system tool belt
   * Follow these Git commit message guidelines
   * Where system, global and local Windows Git config files are saved
   * How Atomist's Rod Johnson works with pull requests
   * Five ways to fix Git's 'fatal: repository not found' error
   * 10 Git quiz questions to test your distributed version control skills



This content is part of the Essential Guide: Master Git basics and branch into
DVCS
News Stay informed about the latest enterprise technology news and product
updates.


WHERE SYSTEM, GLOBAL AND LOCAL GIT CONFIG FILES ON WINDOWS AND UBUNTU LINUX ARE

 * 

Cameron McKenzie
TechTarget
01 Jun 2020

About This Blog

Community driven content discussing all aspects of software development from
DevOps to design patterns.

Latest Blog Posts
 * How to format a Java double with printf example
 * How to setup the Nginx Proxy Manager Docker example
 * Example Java String palindrome checker program using recursion
 * See More

 * Share this item with your network:
 * 
 * 
 * 
 * 
 * 

Sponsored News
 * Optimizing Your Digital Workspaces? Look to Analytics –Citrix
 * The Well-Trod Path From Application Virtualization to People-Centric Digital
   ... –Citrix

Vendor Resources
 * How To - Implementing Effective Automation Strategies –BMC
 * 5 Things You Need to Get Started with Enterprise Progressive Delivery
   –Cloudbees

 * 
 * 
 *  * 
    * 
    * 
    * 


GIT CONFIG FILE LOCATIONS

One of the five basic Git commands beginners need to learn is git config, if for
no other reason than to perform an initial commit without the Git tool pestering
for a user.name and user.email address. But the git config command commonly used
to initialize these fields typically employs a global switch, which gets users
wondering about Git’s competing local and system scopes.



That then leads to the question about where all of these variously scoped Linux
and Windows git configuration files can be found. Here we will answer all of
those questions about Git config file locations and where the various gitconfig
files are stored.

Full list of where the Git configuration files config, gitconfig and .gitconfig
are located on Windows and Ubuntu Linux.


SYSTEM, GLOBAL AND LOCAL GIT CONFIG FILES

Listed in descending order of specificity, Git provides four standard scopes for
storing configuration data, plus a portable scope on Windows:

 1. Worktree
 2. Local
 3. Global
 4. System
 5. Portable

> Note: You will notice a ‘portable scope’ mentioned in the Windows Git config
> table above. This scope was pointed out to me by a reader after this article
> first published. The portable scope is the most general and is overridden by
> all other scopes.

The scopes are cascading with the most specific file taking precedence over the
most general. Local scope overrides global scope. Global scope overrides system
scope.



If you set up multiple Git worktrees on the same computer, you can also use the
Git worktree scope, although doing so requires this scope to be enabled.
Worktree scope is the most specific and will override local.


NAMES OF UNIX AND WINDOWS GIT CONFIG FILES

Just to make life a bit more complicated, the variously scoped Git configuration
files all have different names:

 * gitconfig – the extensionless system Git config file
 * .gitconfig – the global Git config file has no name, but is instead just an
   extension
 * config – the local Git configuration file is simply named config, and like
   the system Git config file, has no extension
 * config.worktree – the Git worktree configuration file flaunts both a name and
   an extension


WHERE ARE WINDOWS GIT CONFIG FILES LOCATED?

Here is where you will find Git configuration files on Windows:

Location of Windows Git Config Files Scope Location and Filename Filename Only
 System  <git-install-root>\mingw64\etc\gitconfig  gitconfig  Global
 C:\Users\username\.gitconfig  .gitconfig  Local  <git-repo>\.git\config  config
 Worktree  <git-repo>\.git\config.worktree  config.worktree  Portable
 C:\ProgramData\Git\config  config


WHERE ARE GIT CONFIG FILES FOR UBUNTU LINUX LOCATED?

As for the location of the Linux Git configuration files, here is where you’ll
find them on Ubuntu:

Ubuntu Linux Git Config File Locations Scope Location and Filename Filename Only
 System  ~etc/gitconfig  gitconfig  Global  ~home/<username>/.gitconfig or
~root/.gitconfig  .gitconfig  Local  <git-repo>/.git/config  config  Worktree
 <git-repo>/.git/config.worktree  config.worktree


FIND GIT CONFIG FILES ON YOUR OWN

To find the Git config file setting a given variable to a particular value, the
–list and –show-origin switches of the git command can be useful. In the
following example you can see the command indicating that the user.email
property is set in the portable, system, local and global scopes. It also states
exactly where those files Git config files are located.

Here is the git config command with list and show-origin swtiches run on
Windows:

windows@location (master)
$ git config --list --show-origin
file:"C:\\ProgramData/Git/config" user.email=portal@example.com
file:C:/_git/mingw64/etc/gitconfig user.name=Syster Sally
file:C:/_git/mingw64/etc/gitconfig user.email=system@example.com
file:C:/Users/Owner/.gitconfig user.email=global@example.com
file:.git/config user.email=local@example.com

Here is the same command run on Ubnutu where the Git user.name property is set
in three separate scopes:

linux@location (master)
$ git config --list --show-origin
file: /etc/gitconfig user.name=Syster Sally
file: /home/gme/.gitconfig user.name=Glow Ball
file: .git/config user.name=Low Cal

On StackOverflow, the following command was suggested to help developers find
the location of the Git config files:

sudo git -c core.editor=ls\ -al config --system --edit

The animated GIF below, pulled from 1998 when such things were cool, shows the
above command being run on Ubuntu 20. Note how the command above lists the home
directory as the location for the global Git config file, but when the sudo
command is used below the global Git config file is in ~root.

Git config file locations on Ubuntu Linux.


CAN’T FIND THE GLOBAL GIT CONFIG FILE .GITCONFIG?

Sometimes users go looking for the global and system Git config files and can’t
find them. If you can’t find gitconfig or .gitconfig, it’s probably because it’s
not there.

Git doesn’t actually create the gitconfig or .gitconfig files until they are
referenced for the first time. Just asking Git to edit the file will force its
creation, but until that happens, efforts to find the .gitconfig or gitconfig
file will be fruitless.

The following operation will likely require sudo rights on a Linux distribution
as you may be creating files in privileged \etc or \root directories. But when
run with elevated permissions, these commands are sufficient enough to force the
creation of global and system gitconfig and .gitconfig files:

/c/ global/windows git config files (master) 
$ sudo git config --edit --global 
$ sudo git config --edit --system

Each of these Git commands will open the corresponding Windows or Linux Git
config file in the configuration specified editor. You may edit the file if you
please, or simply close the editor immediately to force config file creation.

Figure 2. The three main locations of Windows Git configuration files.



On the topic of editors, if you’d like to switch the Git editor to Notepad++,
just issue the following command:

$ git config --global core.editor "'C:/Program Files/Notepad++/notepad++.exe' -multiInst -notabbar -nosession -noPlugin"

Always be careful editing the Git config files, because if you incorrectly edit
any of these files, you just might ruin your entire Linux or Windows Git
configuration.



BECOME A GIT POWER USER

Want to become a powerful Git user? Then take a look at the following Git
articles and tutorials:

 * How to do a Git clean up of branches and commits
 * Learn to rebase onto master and rebase from the master branch
 * Squash all Git commits on a branch down to one
 * Shelve your changes with Git stash pop and apply
 * Easily explain the  Git vs GitHub difference
 * Add a shallow git clone of depth 1 do your Jenkins jobs
 * Set up a local Git server with a bare Git repo



 * About Us
 * Editorial Ethics Policy
 * Meet The Editors
 * Contact Us
 * Advertisers
 * Business Partners
 * Media Kit
 * Corporate Site

 * Contributors
 * Reprints
 * Answers
 * Definitions
 * E-Products
 * Events
 * Features

 * Guides
 * Opinions
 * Photo Stories
 * Quizzes
 * Tips
 * Tutorials
 * Videos

All Rights Reserved, Copyright 2000 - 2022, TechTarget

Privacy Policy
Cookie Preferences
Do Not Sell My Personal Info


Latest TechTarget resources
 * Application Architecture
 * Software Quality
 * Cloud Computing
 * Security
 * AWS

SearchAppArchitecture
 * A 7-point language comparison of Ballerina vs. Golang
   
   This comparison takes a look at both Ballerina and Golang, including their
   support for high-level programming, libraries, ...

 * How viable is it to create microservices in Python?
   
   Python offers microservices developers access to advanced scripting, embedded
   testing and plugin tooling. But is it a good fit ...

 * Ardoq Discover boosts enterprise architecture tool usability
   
   Tools for enterprise architects get criticized for their complexity, but they
   are getting better. A recently released module from...

SearchSoftwareQuality
 * CircleCI vs. GitHub Actions: CI/CD platform comparison
   
   Learn the differing features, commands and perks that make CircleCI and
   GitHub Actions distinct CI/CD platforms. Then, decide ...

 * Key things to consider when choosing regression testing tools
   
   Making a decision about regression testing tooling purchases means taking
   stock of plans for CI/CD implementations, existing ...

 * Amazon CodeWhisperer joins packed AI code completion market
   
   AI code completion tool Amazon CodeWhisperer is now available for developers
   who are willing to wait.

SearchCloudComputing
 * Cloud-native modernization is on the rise
   
   Research suggests that cloud-native application deployment is becoming more
   prevalent as organizations continue to embrace public...

 * IT buyers respond to HPE GreenLake cloud pitch
   
   Tech buyers are interested in the breadth and depth of services sold through
   the HPE GreenLake service, but want proof of cost ...

 * How to create an EC2 instance using PowerShell
   
   PowerShell has practical integrations that provide users with cross-platform
   capabilities. Get to know prerequisites and ...

SearchSecurity
 * SANS Institute: Human error remains the top security issue
   
   The SANS Institute's annual report on security awareness found that human
   risk is still the biggest source of data breaches and ...

 * How to conduct a cyber-resilience assessment
   
   It's a good cyber hygiene practice to periodically review your organization's
   cybersecurity plans and procedures. Use this ...

 * Ransomware gangs using Log4Shell to attack VMware instances
   
   Ransomware groups are exploiting the Log4Shell flaw in VMware Horizon and
   using DLL sideloading techniques to exfiltrate and ...

SearchAWS
 * AWS Control Tower aims to simplify multi-account management
   
   Many organizations struggle to manage their vast collection of AWS accounts,
   but Control Tower can help. The service automates ...

 * Break down the Amazon EKS pricing model
   
   There are several important variables within the Amazon EKS pricing model.
   Dig into the numbers to ensure you deploy the service ...

 * Compare EKS vs. self-managed Kubernetes on AWS
   
   AWS users face a choice when deploying Kubernetes: run it themselves on EC2
   or let Amazon do the heavy lifting with EKS. See ...


Close