If you're using a GUI client, some of these settings may be done via its settings dialog.
Git checks 4 places for a configuration file, cascading settings which means that the more specific config files overwrite or extend settings from the more generic files (machine → global → local → worktree).
Your machine's system-wide configuration file.
--system
<git-install-root>\mingw64\etc\gitconfig
~etc/gitconfig
Your user's global .gitconfig
file.
--global
C:\Users\<username>\.gitconfig
~/.gitconfig
The local repo's config file.
--local
<git-repo>\.git\config
<git-repo>/.git/config
The config file for the git worktree (if configured).
--worktree
<git-repo>\.git\config.worktree
<git-repo>/.git/config.worktree
If extensions.worktreeConfig is not enabled, this is the same as --local
.
You might end up with multiple system-wide configuration files, after installing multiple git instances. To show the configuration keys and values and where they origin from, use
git config --list --show-origin
E.g. when running this command in the git-for-windows git bash, you might see an origin like this
file:C:/Program Files/Git/etc/gitconfig core.symlinks=false
and when running it in the git bash from the git fork client, you might see an origin like this
file:C:/Users/admin/AppData/Local/Fork/gitInstance/2.45.2/etc/gitconfig core.symlinks=false
If you haven't been asked for your name and your email address during installation, you can manually set this information:
git config --global user.name "Your Name" git config --global user.email "your@email.address"
[user] name = Your Name email = your@email.address [core] excludesfile = /some/path/to/.gitignore_global filemode = false
The exludesfile
mentioned in the .gitconfig file (the global .gitignore file) defines which files to ignore (exclude from versioning) for all repositories on the computer its stored on. You can set the path of the global exludesfile to the actual user's home directory with
git config --global core.excludesfile '~/.gitignore'
Each repository and each directory in it can have its own .gitignore file.
# Generic: Temporary Files and Logs *~ ._* .DS_Store Thumbs.db ~*.docx ~*.xlsx *.log*
# LabVIEW Metadata *.aliases *.lvlps .cache/ # LabVIEW Binaries/Builds artifacts/ builds/ *.lvlibp
If you're using msysgit on Windows:
.gitconfig
file resides at %PROGRAMFILES(X86)%\Git\etc\gitconfig
. ~/.gitconfig
file resides at your %HOMEPATH%
Use echo %PROGRAMFILES(X86)%
and echo %HOMEPATH%
from a Windows command prompt to find the specific locations.
Set the global .gitignore file location to C:/users/{myusername}/.gitignore
:
git config --global core.excludesfile "%USERPROFILE%\.gitignore"
The above command will only set the location of the ignore file that git will use. The file has to still be manually created in that location and populated with the ignore list.
Open up My Computer → Advanced System Settings → Environment Variables. Then:
C:\Program Files (X86)\Git\bin
) to the PATH
environment variablemsys
to the TERM
environment variableIf your repository is on a filesystem whose executable bits are unreliable (like FAT), git should be configured to ignore differences in file modes recorded in the index and the file mode on the filesystem if they differ only on executable bit:
git config --local core.filemode false
and/or
git config --global core.filemode false
Due to a Windows API limitation of file paths having 260 or fewer characters, Git checkouts fail on Windows with “Filename too long error: unable to create file” errors if a path is longer than the 260 characters.
To resolve this issue, please run the following command from GitBash or the Git CMD prompt:
git config --system core.longpaths true
If you have divergent branches, git has different ways of reconciling them. You can learn more about this topic in the great Atlassian Tutorials.
git config --global pull.rebase false
git config --global pull.rebase true
git config --global pull.ff only