Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Starting <a href="https://github.com/git/git/blob/5fd09df3937f54c5cfda4f1087f5d99433cce527/Documentation/RelNotes/1.8.5.txt#L115-L116" rel="noreferrer">git 1.8.5 (Q4 2013)</a>, you will be able to "use a Git command, but without having to change directories".</p> <blockquote> <p>Just like "<code>make -C &lt;directory&gt;</code>", <strong>"<code>git -C &lt;directory&gt; ...</code>" tells Git to go there before doing anything else</strong>.</p> </blockquote> <p>See <a href="https://github.com/git/git/commit/44e1e4d67d5148c245db362cc48c3cc6c2ec82ca" rel="noreferrer">commit 44e1e4</a> by <strong><a href="http://perlresume.org/NAZRI" rel="noreferrer">Nazri Ramliy</a></strong>:</p> <blockquote> <p>It takes more keypresses to invoke Git command in a different directory without leaving the current directory:</p> <ol> <li><code>(cd ~/foo &amp;&amp; git status)<br> git --git-dir=~/foo/.git --work-tree=~/foo status<br> GIT_DIR=~/foo/.git GIT_WORK_TREE=~/foo git status</code> </li> <li><code>(cd ../..; git grep foo)</code></li> <li><code>for d in d1 d2 d3; do (cd $d &amp;&amp; git svn rebase); done</code></li> </ol> <p>The methods shown above are acceptable for scripting but are too cumbersome for quick command line invocations.</p> <p>With this new option, the above can be done with fewer keystrokes:</p> <ol> <li><code>git -C ~/foo status</code></li> <li><code>git -C ../.. grep foo</code></li> <li><code>for d in d1 d2 d3; do git -C $d svn rebase; done</code></li> </ol> </blockquote> <hr> <p>Since Git 2.3.4 (March 2015), and <a href="https://github.com/git/git/commit/6a536e2076f02a98e0d6403ff68f3acf717fa1c4" rel="noreferrer">commit 6a536e2</a> by <a href="https://github.com/KarthikNayak" rel="noreferrer">Karthik Nayak (<code>KarthikNayak</code>)</a>, <code>git</code> will treat "<code>git -C '&lt;path&gt;'</code>" as a <strong>no-op when <code>&lt;path&gt;</code> is empty.</strong> </p> <blockquote> <p>'<code>git -C ""</code>' unhelpfully dies with error "<code>Cannot change to ''</code>", whereas the shell treats cd ""' as a no-op.<br> Taking the shell's behavior as a precedent, teach <code>git</code> to treat -C ""' as a no-op, as well.</p> </blockquote>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload