title: exporting entire git configuration to be used with GIT_CONFIG
body: <p>is there any way to dump the <em>entire</em> git configuration that is currently in action (local, global, system) into a file that can then be used as <code>GIT_CONFIG</code> file?</p>
  
  <p>Something like:</p>
  
  <pre class="lang-sh prettyprint-override"><code>$ git config --list &gt; mygit.cfg
  $ GIT_CONFIG=mygit.cfg git clone /path/to/repo.git
  </code></pre>
  
  <p>Unfortunately the above doesn't really do anything (the configuration is not read from the <code>mygit.cfg</code> file but from the standard locations).</p>
  
  <p>Also doing something like:</p>
  
  <pre><code>$ git config --file mygit.cfg --unset foo.bar
  </code></pre>
  
  <p>fails with :</p>
  
  <blockquote>
    <p>fatal: bad config line 1 in file mygit.cfg</p>
  </blockquote>
  
  <p>AFAICT, the reason is that <em>all</em> git configuration files must be <code>INI</code>-style files.
  However, <code>git config --list</code> dumps a plain list of <code>key=value</code> lines, which git cannot use as <code>GIT_CONFIG</code> file.</p>
  
  <p>My use-case is as follows:</p>
  
  <ul>
  <li>I have some git problems (related to cloning a 3rd party repository) on an autobuild host (CI), that are caused by a git configuration setting
  
  <ul>
  <li>since it's an autobuilder changes are not persistent. so I must be able to modify the system in a script</li>
  </ul></li>
  <li>I really don't care (and don't want to bother) on which level that configuration exists (local, global, system,...) as the configuration is created by the autobuilder</li>
  <li>fixing the git problem involves <em>unsetting</em> one of the configuration values
  
  <ul>
  <li>unfortunately it seems that the <code>-c</code> flag to <code>git</code> only allows to <em>set</em> values, but not to unset them</li>
  </ul></li>
  <li>my idea is to just create an accumulated git configuration, remove the offending key from that configuration and use the amended config to do the few operations i need to do. after that, i want to revert to the original configuration</li>
  </ul>
  
  <p>One naive approach is to just concatenate the files for the various configuration levels:</p>
  
  <pre><code>cat /etc/gitconfig ~/.gitconfig .git/config &gt; mygit.cfg
  </code></pre>
  
  <p>Unfortunately this won't do, as I don't know the locations of the configuration files (yay: multi-platform builders!).
  (Also: the actual location of the configuration files is an implementation detail of git; i don't want to rely on such implementation details)</p>
  
  <p>So: can I dump my git configuration in a way that I can use it with git?</p>