CINXE.COM
Git - Environment Variables
<!DOCTYPE html> <html lang="en"> <head> <meta charset='utf-8'> <meta content='IE=edge,chrome=1' http-equiv='X-UA-Compatible'> <meta name="viewport" content="width=device-width, initial-scale=1"> <title>Git - Environment Variables</title> <link href="/favicon.ico" rel='shortcut icon' type='image/x-icon'> <link rel="stylesheet" href="/application.min.css"> <script src="/js/modernizr.js"></script> <script src="/js/modernize.js"></script> </head> <body id="documentation"> <div class="inner"> <header> <a href="/"><img src="/images/logo@2x.png" width="110" height="46" alt="Git" /></a> <span id="tagline"></span> <script type="text/javascript"> const taglines = [ "fast-version-control", "everything-is-local", "distributed-even-if-your-workflow-isnt", "local-branching-on-the-cheap", "distributed-is-the-new-centralized" ]; var tagline = taglines[Math.floor(Math.random() * taglines.length)]; document.getElementById('tagline').innerHTML = '--' + tagline; </script> <form id="search" action="/search/results"> <input id="search-text" name="search" placeholder="Type / to search entire site…" autocomplete="off" type="text" /> </form> <div id="search-results"></div> </header> </div> <div class="inner"> <div id="content-wrapper"> <div tabindex="1" class="sidebar-btn"></div> <aside class="sidebar" id="sidebar"> <nav> <ul> <li> <a href="/about">About</a> <ul> </ul> </li> <li> <a href="/doc" class="active">Documentation</a> <ul class="expanded"> <li> <a href="/docs">Reference</a> </li> <li> <a href="/book" class="active">Book</a> </li> <li> <a href="/videos">Videos</a> </li> <li> <a href="/doc/ext">External Links</a> </li> </ul> </li> <li> <a href="/downloads">Downloads</a> <ul > <li> <a href="/downloads/guis">GUI Clients</a> </li> <li> <a href="/downloads/logos">Logos</a> </li> </ul> </li> <li> <a href="/community">Community</a> </li> </ul> <hr class="sidebar"> <p> This book is available in <a href="/book/en/v2/Git-Internals-Environment-Variables">English</a>. </p> <p> Full translation available in <table> <tr><td><a href="/book/az/v2/Git%e2%80%99in-Daxili-%c4%b0%c5%9fl%c9%99ri-M%c3%bchit-D%c9%99yi%c5%9f%c9%99nl%c9%99ri">azərbaycan dili</a>,</td></tr> <tr><td><a href="/book/bg">български език</a>,</td></tr> <tr><td><a href="/book/de/v2/Git-Interna-Zusammenfassung">Deutsch</a>,</td></tr> <tr><td><a href="/book/es/v2/Los-entresijos-internos-de-Git-Variables-de-entorno">Español</a>,</td></tr> <tr><td><a href="/book/fr/v2/Les-tripes-de-Git-Les-variables-d%e2%80%99environnement">Français</a>,</td></tr> <tr><td><a href="/book/gr">Ελληνικά</a>,</td></tr> <tr><td><a href="/book/ja/v2/Git%e3%81%ae%e5%86%85%e5%81%b4-%e7%92%b0%e5%a2%83%e5%a4%89%e6%95%b0">日本語</a>,</td></tr> <tr><td><a href="/book/ko/v2/Git%ec%9d%98-%eb%82%b4%eb%b6%80-%ed%99%98%ea%b2%bd%eb%b3%80%ec%88%98">한국어</a>,</td></tr> <tr><td><a href="/book/nl/v2/Git-Binnenwerk-Omgevingsvariabelen">Nederlands</a>,</td></tr> <tr><td><a href="/book/ru/v2/Git-%d0%b8%d0%b7%d0%bd%d1%83%d1%82%d1%80%d0%b8-%d0%9f%d0%b5%d1%80%d0%b5%d0%bc%d0%b5%d0%bd%d0%bd%d1%8b%d0%b5-%d0%be%d0%ba%d1%80%d1%83%d0%b6%d0%b5%d0%bd%d0%b8%d1%8f">Русский</a>,</td></tr> <tr><td><a href="/book/sl/v2/Notranjost-Gita-Spremenljivke-okolja">Slovenščina</a>,</td></tr> <tr><td><a href="/book/tl/v2/Mga-Panloob-ng-GIT-Mga-Variable-sa-Kapaligiran">Tagalog</a>,</td></tr> <tr><td><a href="/book/uk/v2/Git-%d0%b7%d1%81%d0%b5%d1%80%d0%b5%d0%b4%d0%b8%d0%bd%d0%b8-%d0%97%d0%bc%d1%96%d0%bd%d0%bd%d1%96-%d1%81%d0%b5%d1%80%d0%b5%d0%b4%d0%be%d0%b2%d0%b8%d1%89%d0%b0">Українська</a></td></tr> <tr><td><a href="/book/zh/v2/Git-%e5%86%85%e9%83%a8%e5%8e%9f%e7%90%86-%e7%8e%af%e5%a2%83%e5%8f%98%e9%87%8f">简体中文</a>,</td></tr> </table> </p> <p> Partial translations available in <table> <tr><td><a href="/book/cs/v2/Git-Internals-Environment-Variables">Čeština</a>,</td></tr> <tr><td><a href="/book/mk/v2/%d0%92%d0%bd%d0%b0%d1%82%d1%80%d0%b5%d1%88%d0%bd%d0%be%d1%81%d1%82%d0%b0-%d0%bd%d0%b0-Git-Environment-Variables">Македонски</a>,</td></tr> <tr><td><a href="/book/pl/v2/Mechanizmy-wewn%c4%99trzne-w-Git-Environment-Variables">Polski</a>,</td></tr> <tr><td><a href="/book/sr/v2/%d0%93%d0%b8%d1%82-%d0%b8%d0%b7%d0%bd%d1%83%d1%82%d1%80%d0%b0-%d0%9f%d1%80%d0%be%d0%bc%d0%b5%d0%bd%d1%99%d0%b8%d0%b2%d0%b5-%d0%be%d0%ba%d1%80%d1%83%d0%b6%d0%b5%d1%9a%d0%b0">Српски</a>,</td></tr> <tr><td><a href="/book/uz/v2/Git-Internals-Environment-Variables">Ўзбекча</a>,</td></tr> <tr><td><a href="/book/zh-tw/v2/Git-Internals-Environment-Variables">繁體中文</a>,</td></tr> </table> </p> <p> Translations started for <table> <tr><td><a href="/book/be/v2/Git-Internals-Environment-Variables">Беларуская</a>,</td></tr> <tr><td><a href="/book/fa/v2/Git-Internals-Environment-Variables" dir="rtl">فارسی</a>,</td></tr> <tr><td><a href="/book/id/v2/Git-Internals-Environment-Variables">Indonesian</a>,</td></tr> <tr><td><a href="/book/it/v2/Git-Internals-Environment-Variables">Italiano</a>,</td></tr> <tr><td><a href="/book/ms/v2/Git-Internals-Environment-Variables">Bahasa Melayu</a>,</td></tr> <tr><td><a href="/book/pt-br/v2/Funcionamento-Interno-do-Git-Vari%c3%a1veis-de-ambiente">Português (Brasil)</a>,</td></tr> <tr><td><a href="/book/pt-pt/v2/Internos-do-Git-Environment-Variables">Português (Portugal)</a>,</td></tr> <tr><td><a href="/book/sv/v2/Git-Internals-Environment-Variables">Svenska</a>,</td></tr> <tr><td><a href="/book/tr/v2/Dahili-Git-%c3%96geleri-Ortam-De%c4%9fi%c5%9fkenleri">Türkçe</a>.</td></tr> </table> </p> <hr class="sidebar"/> <p> The source of this book is <a href="https://github.com/progit/progit2">hosted on GitHub.</a></br> Patches, suggestions and comments are welcome. </p> </nav> </aside> <div id="content"> <div id="book-chapters"> <a class="dropdown-trigger" id="book-chapters-trigger" data-panel-id="chapters-dropdown" href="#">Chapters ▾</a> <div class='dropdown-panel' id='chapters-dropdown'> <div class='three-column'> <div class="column-left"> <ol class='book-toc'> <li class='chapter'> <h2>1. <a href="/book/en/v2/Getting-Started-About-Version-Control">Getting Started</a></h2> <ol> <li> 1.1 <a href="/book/en/v2/Getting-Started-About-Version-Control">About Version Control</a> </li> <li> 1.2 <a href="/book/en/v2/Getting-Started-A-Short-History-of-Git">A Short History of Git</a> </li> <li> 1.3 <a href="/book/en/v2/Getting-Started-What-is-Git%3F">What is Git?</a> </li> <li> 1.4 <a href="/book/en/v2/Getting-Started-The-Command-Line">The Command Line</a> </li> <li> 1.5 <a href="/book/en/v2/Getting-Started-Installing-Git">Installing Git</a> </li> <li> 1.6 <a href="/book/en/v2/Getting-Started-First-Time-Git-Setup">First-Time Git Setup</a> </li> <li> 1.7 <a href="/book/en/v2/Getting-Started-Getting-Help">Getting Help</a> </li> <li> 1.8 <a href="/book/en/v2/Getting-Started-Summary">Summary</a> </li> </ol> </li> <li class='chapter'> <h2>2. <a href="/book/en/v2/Git-Basics-Getting-a-Git-Repository">Git Basics</a></h2> <ol> <li> 2.1 <a href="/book/en/v2/Git-Basics-Getting-a-Git-Repository">Getting a Git Repository</a> </li> <li> 2.2 <a href="/book/en/v2/Git-Basics-Recording-Changes-to-the-Repository">Recording Changes to the Repository</a> </li> <li> 2.3 <a href="/book/en/v2/Git-Basics-Viewing-the-Commit-History">Viewing the Commit History</a> </li> <li> 2.4 <a href="/book/en/v2/Git-Basics-Undoing-Things">Undoing Things</a> </li> <li> 2.5 <a href="/book/en/v2/Git-Basics-Working-with-Remotes">Working with Remotes</a> </li> <li> 2.6 <a href="/book/en/v2/Git-Basics-Tagging">Tagging</a> </li> <li> 2.7 <a href="/book/en/v2/Git-Basics-Git-Aliases">Git Aliases</a> </li> <li> 2.8 <a href="/book/en/v2/Git-Basics-Summary">Summary</a> </li> </ol> </li> <li class='chapter'> <h2>3. <a href="/book/en/v2/Git-Branching-Branches-in-a-Nutshell">Git Branching</a></h2> <ol> <li> 3.1 <a href="/book/en/v2/Git-Branching-Branches-in-a-Nutshell">Branches in a Nutshell</a> </li> <li> 3.2 <a href="/book/en/v2/Git-Branching-Basic-Branching-and-Merging">Basic Branching and Merging</a> </li> <li> 3.3 <a href="/book/en/v2/Git-Branching-Branch-Management">Branch Management</a> </li> <li> 3.4 <a href="/book/en/v2/Git-Branching-Branching-Workflows">Branching Workflows</a> </li> <li> 3.5 <a href="/book/en/v2/Git-Branching-Remote-Branches">Remote Branches</a> </li> <li> 3.6 <a href="/book/en/v2/Git-Branching-Rebasing">Rebasing</a> </li> <li> 3.7 <a href="/book/en/v2/Git-Branching-Summary">Summary</a> </li> </ol> </li> <li class='chapter'> <h2>4. <a href="/book/en/v2/Git-on-the-Server-The-Protocols">Git on the Server</a></h2> <ol> <li> 4.1 <a href="/book/en/v2/Git-on-the-Server-The-Protocols">The Protocols</a> </li> <li> 4.2 <a href="/book/en/v2/Git-on-the-Server-Getting-Git-on-a-Server">Getting Git on a Server</a> </li> <li> 4.3 <a href="/book/en/v2/Git-on-the-Server-Generating-Your-SSH-Public-Key">Generating Your SSH Public Key</a> </li> <li> 4.4 <a href="/book/en/v2/Git-on-the-Server-Setting-Up-the-Server">Setting Up the Server</a> </li> <li> 4.5 <a href="/book/en/v2/Git-on-the-Server-Git-Daemon">Git Daemon</a> </li> <li> 4.6 <a href="/book/en/v2/Git-on-the-Server-Smart-HTTP">Smart HTTP</a> </li> <li> 4.7 <a href="/book/en/v2/Git-on-the-Server-GitWeb">GitWeb</a> </li> <li> 4.8 <a href="/book/en/v2/Git-on-the-Server-GitLab">GitLab</a> </li> <li> 4.9 <a href="/book/en/v2/Git-on-the-Server-Third-Party-Hosted-Options">Third Party Hosted Options</a> </li> <li> 4.10 <a href="/book/en/v2/Git-on-the-Server-Summary">Summary</a> </li> </ol> </li> <li class='chapter'> <h2>5. <a href="/book/en/v2/Distributed-Git-Distributed-Workflows">Distributed Git</a></h2> <ol> <li> 5.1 <a href="/book/en/v2/Distributed-Git-Distributed-Workflows">Distributed Workflows</a> </li> <li> 5.2 <a href="/book/en/v2/Distributed-Git-Contributing-to-a-Project">Contributing to a Project</a> </li> <li> 5.3 <a href="/book/en/v2/Distributed-Git-Maintaining-a-Project">Maintaining a Project</a> </li> <li> 5.4 <a href="/book/en/v2/Distributed-Git-Summary">Summary</a> </li> </ol> </li> </ol> </div> <div class='column-middle'> <ol class='book-toc'> <li class='chapter'> <h2>6. <a href="/book/en/v2/GitHub-Account-Setup-and-Configuration">GitHub</a></h2> <ol> <li> 6.1 <a href="/book/en/v2/GitHub-Account-Setup-and-Configuration">Account Setup and Configuration</a> </li> <li> 6.2 <a href="/book/en/v2/GitHub-Contributing-to-a-Project">Contributing to a Project</a> </li> <li> 6.3 <a href="/book/en/v2/GitHub-Maintaining-a-Project">Maintaining a Project</a> </li> <li> 6.4 <a href="/book/en/v2/GitHub-Managing-an-organization">Managing an organization</a> </li> <li> 6.5 <a href="/book/en/v2/GitHub-Scripting-GitHub">Scripting GitHub</a> </li> <li> 6.6 <a href="/book/en/v2/GitHub-Summary">Summary</a> </li> </ol> </li> <li class='chapter'> <h2>7. <a href="/book/en/v2/Git-Tools-Revision-Selection">Git Tools</a></h2> <ol> <li> 7.1 <a href="/book/en/v2/Git-Tools-Revision-Selection">Revision Selection</a> </li> <li> 7.2 <a href="/book/en/v2/Git-Tools-Interactive-Staging">Interactive Staging</a> </li> <li> 7.3 <a href="/book/en/v2/Git-Tools-Stashing-and-Cleaning">Stashing and Cleaning</a> </li> <li> 7.4 <a href="/book/en/v2/Git-Tools-Signing-Your-Work">Signing Your Work</a> </li> <li> 7.5 <a href="/book/en/v2/Git-Tools-Searching">Searching</a> </li> <li> 7.6 <a href="/book/en/v2/Git-Tools-Rewriting-History">Rewriting History</a> </li> <li> 7.7 <a href="/book/en/v2/Git-Tools-Reset-Demystified">Reset Demystified</a> </li> <li> 7.8 <a href="/book/en/v2/Git-Tools-Advanced-Merging">Advanced Merging</a> </li> <li> 7.9 <a href="/book/en/v2/Git-Tools-Rerere">Rerere</a> </li> <li> 7.10 <a href="/book/en/v2/Git-Tools-Debugging-with-Git">Debugging with Git</a> </li> <li> 7.11 <a href="/book/en/v2/Git-Tools-Submodules">Submodules</a> </li> <li> 7.12 <a href="/book/en/v2/Git-Tools-Bundling">Bundling</a> </li> <li> 7.13 <a href="/book/en/v2/Git-Tools-Replace">Replace</a> </li> <li> 7.14 <a href="/book/en/v2/Git-Tools-Credential-Storage">Credential Storage</a> </li> <li> 7.15 <a href="/book/en/v2/Git-Tools-Summary">Summary</a> </li> </ol> </li> <li class='chapter'> <h2>8. <a href="/book/en/v2/Customizing-Git-Git-Configuration">Customizing Git</a></h2> <ol> <li> 8.1 <a href="/book/en/v2/Customizing-Git-Git-Configuration">Git Configuration</a> </li> <li> 8.2 <a href="/book/en/v2/Customizing-Git-Git-Attributes">Git Attributes</a> </li> <li> 8.3 <a href="/book/en/v2/Customizing-Git-Git-Hooks">Git Hooks</a> </li> <li> 8.4 <a href="/book/en/v2/Customizing-Git-An-Example-Git-Enforced-Policy">An Example Git-Enforced Policy</a> </li> <li> 8.5 <a href="/book/en/v2/Customizing-Git-Summary">Summary</a> </li> </ol> </li> <li class='chapter'> <h2>9. <a href="/book/en/v2/Git-and-Other-Systems-Git-as-a-Client">Git and Other Systems</a></h2> <ol> <li> 9.1 <a href="/book/en/v2/Git-and-Other-Systems-Git-as-a-Client">Git as a Client</a> </li> <li> 9.2 <a href="/book/en/v2/Git-and-Other-Systems-Migrating-to-Git">Migrating to Git</a> </li> <li> 9.3 <a href="/book/en/v2/Git-and-Other-Systems-Summary">Summary</a> </li> </ol> </li> <li class='chapter'> <h2>10. <a href="/book/en/v2/Git-Internals-Plumbing-and-Porcelain">Git Internals</a></h2> <ol> <li> 10.1 <a href="/book/en/v2/Git-Internals-Plumbing-and-Porcelain">Plumbing and Porcelain</a> </li> <li> 10.2 <a href="/book/en/v2/Git-Internals-Git-Objects">Git Objects</a> </li> <li> 10.3 <a href="/book/en/v2/Git-Internals-Git-References">Git References</a> </li> <li> 10.4 <a href="/book/en/v2/Git-Internals-Packfiles">Packfiles</a> </li> <li> 10.5 <a href="/book/en/v2/Git-Internals-The-Refspec">The Refspec</a> </li> <li> 10.6 <a href="/book/en/v2/Git-Internals-Transfer-Protocols">Transfer Protocols</a> </li> <li> 10.7 <a href="/book/en/v2/Git-Internals-Maintenance-and-Data-Recovery">Maintenance and Data Recovery</a> </li> <li> 10.8 <a href="/book/en/v2/Git-Internals-Environment-Variables" class="active">Environment Variables</a> </li> <li> 10.9 <a href="/book/en/v2/Git-Internals-Summary">Summary</a> </li> </ol> </li> </ol> </div> <div class='column-right'> <ol class='book-toc'> <li class='chapter'> <h2>A1. <a href="/book/en/v2/Appendix-A:-Git-in-Other-Environments-Graphical-Interfaces">Appendix A: Git in Other Environments</a></h2> <ol> <li> A1.1 <a href="/book/en/v2/Appendix-A:-Git-in-Other-Environments-Graphical-Interfaces">Graphical Interfaces</a> </li> <li> A1.2 <a href="/book/en/v2/Appendix-A:-Git-in-Other-Environments-Git-in-Visual-Studio">Git in Visual Studio</a> </li> <li> A1.3 <a href="/book/en/v2/Appendix-A:-Git-in-Other-Environments-Git-in-Visual-Studio-Code">Git in Visual Studio Code</a> </li> <li> A1.4 <a href="/book/en/v2/Appendix-A:-Git-in-Other-Environments-Git-in-IntelliJ-/-PyCharm-/-WebStorm-/-PhpStorm-/-RubyMine">Git in IntelliJ / PyCharm / WebStorm / PhpStorm / RubyMine</a> </li> <li> A1.5 <a href="/book/en/v2/Appendix-A:-Git-in-Other-Environments-Git-in-Sublime-Text">Git in Sublime Text</a> </li> <li> A1.6 <a href="/book/en/v2/Appendix-A:-Git-in-Other-Environments-Git-in-Bash">Git in Bash</a> </li> <li> A1.7 <a href="/book/en/v2/Appendix-A:-Git-in-Other-Environments-Git-in-Zsh">Git in Zsh</a> </li> <li> A1.8 <a href="/book/en/v2/Appendix-A:-Git-in-Other-Environments-Git-in-PowerShell">Git in PowerShell</a> </li> <li> A1.9 <a href="/book/en/v2/Appendix-A:-Git-in-Other-Environments-Summary">Summary</a> </li> </ol> </li> <li class='chapter'> <h2>A2. <a href="/book/en/v2/Appendix-B:-Embedding-Git-in-your-Applications-Command-line-Git">Appendix B: Embedding Git in your Applications</a></h2> <ol> <li> A2.1 <a href="/book/en/v2/Appendix-B:-Embedding-Git-in-your-Applications-Command-line-Git">Command-line Git</a> </li> <li> A2.2 <a href="/book/en/v2/Appendix-B:-Embedding-Git-in-your-Applications-Libgit2">Libgit2</a> </li> <li> A2.3 <a href="/book/en/v2/Appendix-B:-Embedding-Git-in-your-Applications-JGit">JGit</a> </li> <li> A2.4 <a href="/book/en/v2/Appendix-B:-Embedding-Git-in-your-Applications-go-git">go-git</a> </li> <li> A2.5 <a href="/book/en/v2/Appendix-B:-Embedding-Git-in-your-Applications-Dulwich">Dulwich</a> </li> </ol> </li> <li class='chapter'> <h2>A3. <a href="/book/en/v2/Appendix-C:-Git-Commands-Setup-and-Config">Appendix C: Git Commands</a></h2> <ol> <li> A3.1 <a href="/book/en/v2/Appendix-C:-Git-Commands-Setup-and-Config">Setup and Config</a> </li> <li> A3.2 <a href="/book/en/v2/Appendix-C:-Git-Commands-Getting-and-Creating-Projects">Getting and Creating Projects</a> </li> <li> A3.3 <a href="/book/en/v2/Appendix-C:-Git-Commands-Basic-Snapshotting">Basic Snapshotting</a> </li> <li> A3.4 <a href="/book/en/v2/Appendix-C:-Git-Commands-Branching-and-Merging">Branching and Merging</a> </li> <li> A3.5 <a href="/book/en/v2/Appendix-C:-Git-Commands-Sharing-and-Updating-Projects">Sharing and Updating Projects</a> </li> <li> A3.6 <a href="/book/en/v2/Appendix-C:-Git-Commands-Inspection-and-Comparison">Inspection and Comparison</a> </li> <li> A3.7 <a href="/book/en/v2/Appendix-C:-Git-Commands-Debugging">Debugging</a> </li> <li> A3.8 <a href="/book/en/v2/Appendix-C:-Git-Commands-Patching">Patching</a> </li> <li> A3.9 <a href="/book/en/v2/Appendix-C:-Git-Commands-Email">Email</a> </li> <li> A3.10 <a href="/book/en/v2/Appendix-C:-Git-Commands-External-Systems">External Systems</a> </li> <li> A3.11 <a href="/book/en/v2/Appendix-C:-Git-Commands-Administration">Administration</a> </li> <li> A3.12 <a href="/book/en/v2/Appendix-C:-Git-Commands-Plumbing-Commands">Plumbing Commands</a> </li> </ol> </li> </ol> </div> </div> </div> <span class="light" id="edition"> 2nd Edition </span> </div> <div id="main" data-pagefind-filter="category:book" data-pagefind-meta="category:Book" data-pagefind-weight="0.05" data-pagefind-body class="book edition2"> <h1>10.8 Git Internals - Environment Variables</h1> <div> <h2 id="_environment_variables">Environment Variables</h2> <div class="paragraph"> <p>Git always runs inside a <code>bash</code> shell, and uses a number of shell environment variables to determine how it behaves. Occasionally, it comes in handy to know what these are, and how they can be used to make Git behave the way you want it to. This isn’t an exhaustive list of all the environment variables Git pays attention to, but we’ll cover the most useful.</p> </div> <div class="sect3"> <h3 id="_global_behavior">Global Behavior</h3> <div class="paragraph"> <p>Some of Git’s general behavior as a computer program depends on environment variables.</p> </div> <div class="paragraph"> <p><strong><code>GIT_EXEC_PATH</code></strong> determines where Git looks for its sub-programs (like <code>git-commit</code>, <code>git-diff</code>, and others). You can check the current setting by running <code>git --exec-path</code>.</p> </div> <div class="paragraph"> <p><strong><code>HOME</code></strong> isn’t usually considered customizable (too many other things depend on it), but it’s where Git looks for the global configuration file. If you want a truly portable Git installation, complete with global configuration, you can override <code>HOME</code> in the portable Git’s shell profile.</p> </div> <div class="paragraph"> <p><strong><code>PREFIX</code></strong> is similar, but for the system-wide configuration. Git looks for this file at <code>$PREFIX/etc/gitconfig</code>.</p> </div> <div class="paragraph"> <p><strong><code>GIT_CONFIG_NOSYSTEM</code></strong>, if set, disables the use of the system-wide configuration file. This is useful if your system config is interfering with your commands, but you don’t have access to change or remove it.</p> </div> <div class="paragraph"> <p><strong><code>GIT_PAGER</code></strong> controls the program used to display multi-page output on the command line. If this is unset, <code>PAGER</code> will be used as a fallback.</p> </div> <div class="paragraph"> <p><strong><code>GIT_EDITOR</code></strong> is the editor Git will launch when the user needs to edit some text (a commit message, for example). If unset, <code>EDITOR</code> will be used.</p> </div> </div> <div class="sect3"> <h3 id="_repository_locations">Repository Locations</h3> <div class="paragraph"> <p>Git uses several environment variables to determine how it interfaces with the current repository.</p> </div> <div class="paragraph"> <p><strong><code>GIT_DIR</code></strong> is the location of the <code>.git</code> folder. If this isn’t specified, Git walks up the directory tree until it gets to <code>~</code> or <code>/</code>, looking for a <code>.git</code> directory at every step.</p> </div> <div class="paragraph"> <p><strong><code>GIT_CEILING_DIRECTORIES</code></strong> controls the behavior of searching for a <code>.git</code> directory. If you access directories that are slow to load (such as those on a tape drive, or across a slow network connection), you may want to have Git stop trying earlier than it might otherwise, especially if Git is invoked when building your shell prompt.</p> </div> <div class="paragraph"> <p><strong><code>GIT_WORK_TREE</code></strong> is the location of the root of the working directory for a non-bare repository. If <code>--git-dir</code> or <code>GIT_DIR</code> is specified but none of <code>--work-tree</code>, <code>GIT_WORK_TREE</code> or <code>core.worktree</code> is specified, the current working directory is regarded as the top level of your working tree.</p> </div> <div class="paragraph"> <p><strong><code>GIT_INDEX_FILE</code></strong> is the path to the index file (non-bare repositories only).</p> </div> <div class="paragraph"> <p><strong><code>GIT_OBJECT_DIRECTORY</code></strong> can be used to specify the location of the directory that usually resides at <code>.git/objects</code>.</p> </div> <div class="paragraph"> <p><strong><code>GIT_ALTERNATE_OBJECT_DIRECTORIES</code></strong> is a colon-separated list (formatted like <code>/dir/one:/dir/two:…</code>) which tells Git where to check for objects if they aren’t in <code>GIT_OBJECT_DIRECTORY</code>. If you happen to have a lot of projects with large files that have the exact same contents, this can be used to avoid storing too many copies of them.</p> </div> </div> <div class="sect3"> <h3 id="_pathspecs">Pathspecs</h3> <div class="paragraph"> <p>A “pathspec” refers to how you specify paths to things in Git, including the use of wildcards. These are used in the <code>.gitignore</code> file, but also on the command-line (<code>git add *.c</code>).</p> </div> <div class="paragraph"> <p><strong><code>GIT_GLOB_PATHSPECS</code></strong> and <strong><code>GIT_NOGLOB_PATHSPECS</code></strong> control the default behavior of wildcards in pathspecs. If <code>GIT_GLOB_PATHSPECS</code> is set to 1, wildcard characters act as wildcards (which is the default); if <code>GIT_NOGLOB_PATHSPECS</code> is set to 1, wildcard characters only match themselves, meaning something like <code>*.c</code> would only match a file <em>named</em> “\*.c”, rather than any file whose name ends with <code>.c</code>. You can override this in individual cases by starting the pathspec with <code>:(glob)</code> or <code>:(literal)</code>, as in <code>:(glob)\*.c</code>.</p> </div> <div class="paragraph"> <p><strong><code>GIT_LITERAL_PATHSPECS</code></strong> disables both of the above behaviors; no wildcard characters will work, and the override prefixes are disabled as well.</p> </div> <div class="paragraph"> <p><strong><code>GIT_ICASE_PATHSPECS</code></strong> sets all pathspecs to work in a case-insensitive manner.</p> </div> </div> <div class="sect3"> <h3 id="_committing">Committing</h3> <div class="paragraph"> <p>The final creation of a Git commit object is usually done by <code>git-commit-tree</code>, which uses these environment variables as its primary source of information, falling back to configuration values only if these aren’t present.</p> </div> <div class="paragraph"> <p><strong><code>GIT_AUTHOR_NAME</code></strong> is the human-readable name in the “author” field.</p> </div> <div class="paragraph"> <p><strong><code>GIT_AUTHOR_EMAIL</code></strong> is the email for the “author” field.</p> </div> <div class="paragraph"> <p><strong><code>GIT_AUTHOR_DATE</code></strong> is the timestamp used for the “author” field.</p> </div> <div class="paragraph"> <p><strong><code>GIT_COMMITTER_NAME</code></strong> sets the human name for the “committer” field.</p> </div> <div class="paragraph"> <p><strong><code>GIT_COMMITTER_EMAIL</code></strong> is the email address for the “committer” field.</p> </div> <div class="paragraph"> <p><strong><code>GIT_COMMITTER_DATE</code></strong> is used for the timestamp in the “committer” field.</p> </div> <div class="paragraph"> <p><strong><code>EMAIL</code></strong> is the fallback email address in case the <code>user.email</code> configuration value isn’t set. If <em>this</em> isn’t set, Git falls back to the system user and host names.</p> </div> </div> <div class="sect3"> <h3 id="_networking">Networking</h3> <div class="paragraph"> <p>Git uses the <code>curl</code> library to do network operations over HTTP, so <strong><code>GIT_CURL_VERBOSE</code></strong> tells Git to emit all the messages generated by that library. This is similar to doing <code>curl -v</code> on the command line.</p> </div> <div class="paragraph"> <p><strong><code>GIT_SSL_NO_VERIFY</code></strong> tells Git not to verify SSL certificates. This can sometimes be necessary if you’re using a self-signed certificate to serve Git repositories over HTTPS, or you’re in the middle of setting up a Git server but haven’t installed a full certificate yet.</p> </div> <div class="paragraph"> <p>If the data rate of an HTTP operation is lower than <strong><code>GIT_HTTP_LOW_SPEED_LIMIT</code></strong> bytes per second for longer than <strong><code>GIT_HTTP_LOW_SPEED_TIME</code></strong> seconds, Git will abort that operation. These values override the <code>http.lowSpeedLimit</code> and <code>http.lowSpeedTime</code> configuration values.</p> </div> <div class="paragraph"> <p><strong><code>GIT_HTTP_USER_AGENT</code></strong> sets the user-agent string used by Git when communicating over HTTP. The default is a value like <code>git/2.0.0</code>.</p> </div> </div> <div class="sect3"> <h3 id="_diffing_and_merging">Diffing and Merging</h3> <div class="paragraph"> <p><strong><code>GIT_DIFF_OPTS</code></strong> is a bit of a misnomer. The only valid values are <code>-u<n></code> or <code>--unified=<n></code>, which controls the number of context lines shown in a <code>git diff</code> command.</p> </div> <div class="paragraph"> <p><strong><code>GIT_EXTERNAL_DIFF</code></strong> is used as an override for the <code>diff.external</code> configuration value. If it’s set, Git will invoke this program when <code>git diff</code> is invoked.</p> </div> <div class="paragraph"> <p><strong><code>GIT_DIFF_PATH_COUNTER</code></strong> and <strong><code>GIT_DIFF_PATH_TOTAL</code></strong> are useful from inside the program specified by <code>GIT_EXTERNAL_DIFF</code> or <code>diff.external</code>. The former represents which file in a series is being diffed (starting with 1), and the latter is the total number of files in the batch.</p> </div> <div class="paragraph"> <p><strong><code>GIT_MERGE_VERBOSITY</code></strong> controls the output for the recursive merge strategy. The allowed values are as follows:</p> </div> <div class="ulist"> <ul> <li> <p>0 outputs nothing, except possibly a single error message.</p> </li> <li> <p>1 shows only conflicts.</p> </li> <li> <p>2 also shows file changes.</p> </li> <li> <p>3 shows when files are skipped because they haven’t changed.</p> </li> <li> <p>4 shows all paths as they are processed.</p> </li> <li> <p>5 and above show detailed debugging information.</p> </li> </ul> </div> <div class="paragraph"> <p>The default value is 2.</p> </div> </div> <div class="sect3"> <h3 id="_debugging">Debugging</h3> <div class="paragraph"> <p>Want to <em>really</em> know what Git is up to? Git has a fairly complete set of traces embedded, and all you need to do is turn them on. The possible values of these variables are as follows:</p> </div> <div class="ulist"> <ul> <li> <p>“true”, “1”, or “2” – the trace category is written to stderr.</p> </li> <li> <p>An absolute path starting with <code>/</code> – the trace output will be written to that file.</p> </li> </ul> </div> <div class="paragraph"> <p><strong><code>GIT_TRACE</code></strong> controls general traces, which don’t fit into any specific category. This includes the expansion of aliases, and delegation to other sub-programs.</p> </div> <div class="listingblock"> <div class="content"> <pre class="highlight"><code class="language-console" data-lang="console">$ GIT_TRACE=true git lga 20:12:49.877982 git.c:554 trace: exec: 'git-lga' 20:12:49.878369 run-command.c:341 trace: run_command: 'git-lga' 20:12:49.879529 git.c:282 trace: alias expansion: lga => 'log' '--graph' '--pretty=oneline' '--abbrev-commit' '--decorate' '--all' 20:12:49.879885 git.c:349 trace: built-in: git 'log' '--graph' '--pretty=oneline' '--abbrev-commit' '--decorate' '--all' 20:12:49.899217 run-command.c:341 trace: run_command: 'less' 20:12:49.899675 run-command.c:192 trace: exec: 'less'</code></pre> </div> </div> <div class="paragraph"> <p><strong><code>GIT_TRACE_PACK_ACCESS</code></strong> controls tracing of packfile access. The first field is the packfile being accessed, the second is the offset within that file:</p> </div> <div class="listingblock"> <div class="content"> <pre class="highlight"><code class="language-console" data-lang="console">$ GIT_TRACE_PACK_ACCESS=true git status 20:10:12.081397 sha1_file.c:2088 .git/objects/pack/pack-c3fa...291e.pack 12 20:10:12.081886 sha1_file.c:2088 .git/objects/pack/pack-c3fa...291e.pack 34662 20:10:12.082115 sha1_file.c:2088 .git/objects/pack/pack-c3fa...291e.pack 35175 # […] 20:10:12.087398 sha1_file.c:2088 .git/objects/pack/pack-e80e...e3d2.pack 56914983 20:10:12.087419 sha1_file.c:2088 .git/objects/pack/pack-e80e...e3d2.pack 14303666 On branch master Your branch is up-to-date with 'origin/master'. nothing to commit, working directory clean</code></pre> </div> </div> <div class="paragraph"> <p><strong><code>GIT_TRACE_PACKET</code></strong> enables packet-level tracing for network operations.</p> </div> <div class="listingblock"> <div class="content"> <pre class="highlight"><code class="language-console" data-lang="console">$ GIT_TRACE_PACKET=true git ls-remote origin 20:15:14.867043 pkt-line.c:46 packet: git< # service=git-upload-pack 20:15:14.867071 pkt-line.c:46 packet: git< 0000 20:15:14.867079 pkt-line.c:46 packet: git< 97b8860c071898d9e162678ea1035a8ced2f8b1f HEAD\0multi_ack thin-pack side-band side-band-64k ofs-delta shallow no-progress include-tag multi_ack_detailed no-done symref=HEAD:refs/heads/master agent=git/2.0.4 20:15:14.867088 pkt-line.c:46 packet: git< 0f20ae29889d61f2e93ae00fd34f1cdb53285702 refs/heads/ab/add-interactive-show-diff-func-name 20:15:14.867094 pkt-line.c:46 packet: git< 36dc827bc9d17f80ed4f326de21247a5d1341fbc refs/heads/ah/doc-gitk-config # […]</code></pre> </div> </div> <div class="paragraph"> <p><strong><code>GIT_TRACE_PERFORMANCE</code></strong> controls logging of performance data. The output shows how long each particular <code>git</code> invocation takes.</p> </div> <div class="listingblock"> <div class="content"> <pre class="highlight"><code class="language-console" data-lang="console">$ GIT_TRACE_PERFORMANCE=true git gc 20:18:19.499676 trace.c:414 performance: 0.374835000 s: git command: 'git' 'pack-refs' '--all' '--prune' 20:18:19.845585 trace.c:414 performance: 0.343020000 s: git command: 'git' 'reflog' 'expire' '--all' Counting objects: 170994, done. Delta compression using up to 8 threads. Compressing objects: 100% (43413/43413), done. Writing objects: 100% (170994/170994), done. Total 170994 (delta 126176), reused 170524 (delta 125706) 20:18:23.567927 trace.c:414 performance: 3.715349000 s: git command: 'git' 'pack-objects' '--keep-true-parents' '--honor-pack-keep' '--non-empty' '--all' '--reflog' '--unpack-unreachable=2.weeks.ago' '--local' '--delta-base-offset' '.git/objects/pack/.tmp-49190-pack' 20:18:23.584728 trace.c:414 performance: 0.000910000 s: git command: 'git' 'prune-packed' 20:18:23.605218 trace.c:414 performance: 0.017972000 s: git command: 'git' 'update-server-info' 20:18:23.606342 trace.c:414 performance: 3.756312000 s: git command: 'git' 'repack' '-d' '-l' '-A' '--unpack-unreachable=2.weeks.ago' Checking connectivity: 170994, done. 20:18:25.225424 trace.c:414 performance: 1.616423000 s: git command: 'git' 'prune' '--expire' '2.weeks.ago' 20:18:25.232403 trace.c:414 performance: 0.001051000 s: git command: 'git' 'rerere' 'gc' 20:18:25.233159 trace.c:414 performance: 6.112217000 s: git command: 'git' 'gc'</code></pre> </div> </div> <div class="paragraph"> <p><strong><code>GIT_TRACE_SETUP</code></strong> shows information about what Git is discovering about the repository and environment it’s interacting with.</p> </div> <div class="listingblock"> <div class="content"> <pre class="highlight"><code class="language-console" data-lang="console">$ GIT_TRACE_SETUP=true git status 20:19:47.086765 trace.c:315 setup: git_dir: .git 20:19:47.087184 trace.c:316 setup: worktree: /Users/ben/src/git 20:19:47.087191 trace.c:317 setup: cwd: /Users/ben/src/git 20:19:47.087194 trace.c:318 setup: prefix: (null) On branch master Your branch is up-to-date with 'origin/master'. nothing to commit, working directory clean</code></pre> </div> </div> </div> <div class="sect3"> <h3 id="_miscellaneous">Miscellaneous</h3> <div class="paragraph"> <p><strong><code>GIT_SSH</code></strong>, if specified, is a program that is invoked instead of <code>ssh</code> when Git tries to connect to an SSH host. It is invoked like <code>$GIT_SSH [username@]host [-p <port>] <command></code>. Note that this isn’t the easiest way to customize how <code>ssh</code> is invoked; it won’t support extra command-line parameters. To support extra command-line parameters, you can use <strong><code>GIT_SSH_COMMAND</code></strong>, write a wrapper script and set <code>GIT_SSH</code> to point to it or use the <code>~/.ssh/config</code> file.</p> </div> <div class="paragraph"> <p><strong><code>GIT_SSH_COMMAND</code></strong> sets the SSH command used when Git tries to connect to an SSH host. The command is interpreted by the shell, and extra command-line arguments can be used with <code>ssh</code>, such as <code>GIT_SSH_COMMAND="ssh -i ~/.ssh/my_key" git clone <a href="mailto:git@example.com">git@example.com</a>:my/repo</code>.</p> </div> <div class="paragraph"> <p><strong><code>GIT_ASKPASS</code></strong> is an override for the <code>core.askpass</code> configuration value. This is the program invoked whenever Git needs to ask the user for credentials, which can expect a text prompt as a command-line argument, and should return the answer on <code>stdout</code> (see <a href="/book/en/v2/ch00/_credential_caching">Credential Storage</a> for more on this subsystem).</p> </div> <div class="paragraph"> <p><strong><code>GIT_NAMESPACE</code></strong> controls access to namespaced refs, and is equivalent to the <code>--namespace</code> flag. This is mostly useful on the server side, where you may want to store multiple forks of a single repository in one repository, only keeping the refs separate.</p> </div> <div class="paragraph"> <p><strong><code>GIT_FLUSH</code></strong> can be used to force Git to use non-buffered I/O when writing incrementally to stdout. A value of 1 causes Git to flush more often, a value of 0 causes all output to be buffered. The default value (if this variable is not set) is to choose an appropriate buffering scheme depending on the activity and the output mode.</p> </div> <div class="paragraph"> <p><strong><code>GIT_REFLOG_ACTION</code></strong> lets you specify the descriptive text written to the reflog. Here’s an example:</p> </div> <div class="listingblock"> <div class="content"> <pre class="highlight"><code class="language-console" data-lang="console">$ GIT_REFLOG_ACTION="my action" git commit --allow-empty -m 'My message' [master 9e3d55a] My message $ git reflog -1 9e3d55a HEAD@{0}: my action: My message</code></pre> </div> </div> </div> <div id="nav"><a href="/book/en/v2/Git-Internals-Maintenance-and-Data-Recovery">prev</a> | <a href="/book/en/v2/Git-Internals-Summary">next</a></div> </div> </div> </div> </div> <footer> <div class="site-source"> <a href="/site">About this site</a><br> Patches, suggestions, and comments are welcome. </div> <div class="sfc-member"> Git is a member of <a href="/sfc">Software Freedom Conservancy</a> </div> </footer> <a href="#top" class="no-js scrollToTop" id="scrollToTop" data-label="Scroll to top"> <img src="/images/icons/chevron-up@2x.png" width="20" height="20" alt="scroll-to-top"/> </a> <script src="/js/jquery-1.7.1.min.js"></script> <script src="/js/jquery-ui-1.8.18.custom.min.js"></script> <script src="/js/jquery.defaultvalue.js"></script> <script src="/js/session.min.js"></script> <script src="/js/application.min.js"></script> </div> </body> </html>