Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>You will need to make sure that both the two following properties are met:</p> <ol> <li><p>That there are no differences between HEAD and the index cache</p> <p><code>git diff-index --cached HEAD</code></p></li> <li><p>That there are no differences between the index and the working tree:</p> <p><code>git diff-files</code></p></li> </ol> <p>Both commands take a <code>--quiet</code> parameter which will set the exit code according to whether there are differences or not (starting some time after git 1.4). If you need to make it work on git 1.4, you need to run the commands without <code>--quiet</code> and check whether they produce any output.</p> <p><strong>Note:</strong> <code>git diff</code> is a porcelain command, and thus should not be used in scripts. Use above plumbing commands instead.</p> <p>Example shell code, taken from my <a href="http://cgit.freedesktop.org/xorg/driver/xf86-video-radeonhd/tree/git_version.sh" rel="nofollow noreferrer">git_version.sh script</a>:</p> <pre><code>git_dirty=yes # git-1.4 does not understand "git-diff-files --quiet" # git-1.4 does not understand "git-diff-index --cached --quiet HEAD" if [ "x$($GIT diff-files)" = "x" ] &amp;&amp; [ "x$($GIT diff-index --cached HEAD)" = "x" ]; then git_dirty=no fi </code></pre> <p>If you can require a git version >= 1.5, <code>if git diff-files --quiet &amp;&amp; git diff-index --quiet --cached HEAD; then</code> can replace above comparison.</p> <p><strong>Note:</strong> This solution (exactly like Antony's interactive <code>git diff HEAD --quiet</code>) only discovers <em>local changes</em> relative to HEAD. However, local commits can arguable also be considered <em>local changes</em>, and naturally will not show up in any diff against HEAD. You will need to check the SHA1 value <code>git describe</code> uses to detect whether HEAD is from a set of commits you consider not to be <em>local changes</em>.</p>
    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