Git environment variables can be set in your shell environment or directly in your Git configuration files (.gitconfig
, ~/.gitconfig
, or /etc/gitconfig
). Environment variables set in your shell are temporary and only apply to the current session, while those in Git configuration files are persistent and apply to all sessions.
To set an environment variable temporarily in your shell, you can use the export
command:
export GIT_EDITOR=nano
For persistent settings, add them to your .gitconfig
:
[core]
editor = nano
Some Useful Git Environment Variables
GIT_EDITOR
: is the editor Git will launch when the user needs to edit some text (a commit message, for example). If unset, EDITOR will be used.GIT_TRACE
: controls general traces, which don’t fit into any specific category. This includes the expansion of aliases, and delegation to other sub-programs.GIT_CURL_VERBOSE
: Git uses the curl library to do network operations over HTTP, soGIT_CURL_VERBOSE
tells Git to emit all the messages generated by that library. This is similar to doingcurl -v
on the command line.
http.postBuffer
One specific Git configuration that often comes into play when dealing with large repositories
or slow network connections
is http.postBuffer
. This option determines the size of the buffer that Git uses when pushing data to a remote repository over HTTP or HTTPS. If you encounter issues pushing large amounts of data, increasing the post buffer size can help.
The default buffer size is 1 MiB
, but you can increase it if needed:
git config --global http.postBuffer 524288000
This command increases the buffer size to 500 MiB. You can read more about it over here.