OSDN Git Service

Add Git official document to help
[tortoisegit/TortoiseGitJp.git] / doc / source / en / TortoiseGit / git_doc / git-update-index.html.xml
diff --git a/doc/source/en/TortoiseGit/git_doc/git-update-index.html.xml b/doc/source/en/TortoiseGit/git_doc/git-update-index.html.xml
new file mode 100644 (file)
index 0000000..afb6adb
--- /dev/null
@@ -0,0 +1,520 @@
+<?xml version="1.0" encoding="UTF-8"?>\r
+<!DOCTYPE article PUBLIC "-//OASIS//DTD DocBook XML V4.2//EN" "http://www.oasis-open.org/docbook/xml/4.2/docbookx.dtd">\r
+\r
+<article lang="en" id="git-update-index(1)">\r
+<articleinfo>\r
+    <title>git-update-index(1)</title>\r
+        <indexterm>\r
+                <primary>git-update-index(1)</primary>\r
+        </indexterm>\r
+</articleinfo>\r
+<simplesect id="_name">\r
+<title>NAME</title>\r
+<simpara>git-update-index - Register file contents in the working tree to the index</simpara>\r
+</simplesect>\r
+<simplesect id="_synopsis">\r
+<title>SYNOPSIS</title>\r
+<blockquote>\r
+<literallayout><emphasis>git update-index</emphasis>\r
+             [--add] [--remove | --force-remove] [--replace]\r
+             [--refresh] [-q] [--unmerged] [--ignore-missing]\r
+             [--cacheinfo &lt;mode&gt; &lt;object&gt; &lt;file&gt;]*\r
+             [--chmod=(+|-)x]\r
+             [--assume-unchanged | --no-assume-unchanged]\r
+             [--ignore-submodules]\r
+             [--really-refresh] [--unresolve] [--again | -g]\r
+             [--info-only] [--index-info]\r
+             [-z] [--stdin]\r
+             [--verbose]\r
+             [--] [&lt;file&gt;]\*</literallayout>\r
+</blockquote>\r
+</simplesect>\r
+<simplesect id="_description">\r
+<title>DESCRIPTION</title>\r
+<simpara>Modifies the index or directory cache. Each file mentioned is updated\r
+into the index and any <emphasis>unmerged</emphasis> or <emphasis>needs updating</emphasis> state is\r
+cleared.</simpara>\r
+<simpara>See also <xref linkend="git-add(1)"/> for a more user-friendly way to do some of\r
+the most common operations on the index.</simpara>\r
+<simpara>The way <emphasis>git-update-index</emphasis> handles files it is told about can be modified\r
+using the various options:</simpara>\r
+</simplesect>\r
+<simplesect id="_options">\r
+<title>OPTIONS</title>\r
+<variablelist>\r
+<varlistentry>\r
+<term>\r
+--add\r
+</term>\r
+<listitem>\r
+<simpara>\r
+        If a specified file isn&#8217;t in the index already then it&#8217;s\r
+        added.\r
+        Default behaviour is to ignore new files.\r
+</simpara>\r
+</listitem>\r
+</varlistentry>\r
+<varlistentry>\r
+<term>\r
+--remove\r
+</term>\r
+<listitem>\r
+<simpara>\r
+        If a specified file is in the index but is missing then it&#8217;s\r
+        removed.\r
+        Default behavior is to ignore removed file.\r
+</simpara>\r
+</listitem>\r
+</varlistentry>\r
+<varlistentry>\r
+<term>\r
+--refresh\r
+</term>\r
+<listitem>\r
+<simpara>\r
+        Looks at the current index and checks to see if merges or\r
+        updates are needed by checking stat() information.\r
+</simpara>\r
+</listitem>\r
+</varlistentry>\r
+<varlistentry>\r
+<term>\r
+-q\r
+</term>\r
+<listitem>\r
+<simpara>\r
+        Quiet.  If --refresh finds that the index needs an update, the\r
+        default behavior is to error out.  This option makes\r
+        <emphasis>git-update-index</emphasis> continue anyway.\r
+</simpara>\r
+</listitem>\r
+</varlistentry>\r
+<varlistentry>\r
+<term>\r
+--ignore-submodules\r
+</term>\r
+<listitem>\r
+<simpara>\r
+        Do not try to update submodules.  This option is only respected\r
+        when passed before --refresh.\r
+</simpara>\r
+</listitem>\r
+</varlistentry>\r
+<varlistentry>\r
+<term>\r
+--unmerged\r
+</term>\r
+<listitem>\r
+<simpara>\r
+        If --refresh finds unmerged changes in the index, the default\r
+        behavior is to error out.  This option makes <emphasis>git-update-index</emphasis>\r
+        continue anyway.\r
+</simpara>\r
+</listitem>\r
+</varlistentry>\r
+<varlistentry>\r
+<term>\r
+--ignore-missing\r
+</term>\r
+<listitem>\r
+<simpara>\r
+        Ignores missing files during a --refresh\r
+</simpara>\r
+</listitem>\r
+</varlistentry>\r
+<varlistentry>\r
+<term>\r
+--cacheinfo &lt;mode&gt; &lt;object&gt; &lt;path&gt;\r
+</term>\r
+<listitem>\r
+<simpara>\r
+        Directly insert the specified info into the index.\r
+</simpara>\r
+</listitem>\r
+</varlistentry>\r
+<varlistentry>\r
+<term>\r
+--index-info\r
+</term>\r
+<listitem>\r
+<simpara>\r
+        Read index information from stdin.\r
+</simpara>\r
+</listitem>\r
+</varlistentry>\r
+<varlistentry>\r
+<term>\r
+--chmod=(+|-)x\r
+</term>\r
+<listitem>\r
+<simpara>\r
+        Set the execute permissions on the updated files.\r
+</simpara>\r
+</listitem>\r
+</varlistentry>\r
+<varlistentry>\r
+<term>\r
+--assume-unchanged\r
+</term>\r
+<term>\r
+--no-assume-unchanged\r
+</term>\r
+<listitem>\r
+<simpara>\r
+        When these flags are specified, the object names recorded\r
+        for the paths are not updated.  Instead, these options\r
+        set and unset the "assume unchanged" bit for the\r
+        paths.  When the "assume unchanged" bit is on, git stops\r
+        checking the working tree files for possible\r
+        modifications, so you need to manually unset the bit to\r
+        tell git when you change the working tree file. This is\r
+        sometimes helpful when working with a big project on a\r
+        filesystem that has very slow lstat(2) system call\r
+        (e.g. cifs).\r
+</simpara>\r
+<simpara>This option can be also used as a coarse file-level mechanism\r
+to ignore uncommitted changes in tracked files (akin to what\r
+<literal>.gitignore</literal> does for untracked files).\r
+You should remember that an explicit <emphasis>git add</emphasis> operation will\r
+still cause the file to be refreshed from the working tree.\r
+Git will fail (gracefully) in case it needs to modify this file\r
+in the index e.g. when merging in a commit;\r
+thus, in case the assumed-untracked file is changed upstream,\r
+you will need to handle the situation manually.</simpara>\r
+</listitem>\r
+</varlistentry>\r
+<varlistentry>\r
+<term>\r
+-g\r
+</term>\r
+<term>\r
+--again\r
+</term>\r
+<listitem>\r
+<simpara>\r
+        Runs <emphasis>git-update-index</emphasis> itself on the paths whose index\r
+        entries are different from those from the <literal>HEAD</literal> commit.\r
+</simpara>\r
+</listitem>\r
+</varlistentry>\r
+<varlistentry>\r
+<term>\r
+--unresolve\r
+</term>\r
+<listitem>\r
+<simpara>\r
+        Restores the <emphasis>unmerged</emphasis> or <emphasis>needs updating</emphasis> state of a\r
+        file during a merge if it was cleared by accident.\r
+</simpara>\r
+</listitem>\r
+</varlistentry>\r
+<varlistentry>\r
+<term>\r
+--info-only\r
+</term>\r
+<listitem>\r
+<simpara>\r
+        Do not create objects in the object database for all\r
+        &lt;file&gt; arguments that follow this flag; just insert\r
+        their object IDs into the index.\r
+</simpara>\r
+</listitem>\r
+</varlistentry>\r
+<varlistentry>\r
+<term>\r
+--force-remove\r
+</term>\r
+<listitem>\r
+<simpara>\r
+        Remove the file from the index even when the working directory\r
+        still has such a file. (Implies --remove.)\r
+</simpara>\r
+</listitem>\r
+</varlistentry>\r
+<varlistentry>\r
+<term>\r
+--replace\r
+</term>\r
+<listitem>\r
+<simpara>\r
+        By default, when a file <literal>path</literal> exists in the index,\r
+        <emphasis>git-update-index</emphasis> refuses an attempt to add <literal>path/file</literal>.\r
+        Similarly if a file <literal>path/file</literal> exists, a file <literal>path</literal>\r
+        cannot be added.  With --replace flag, existing entries\r
+        that conflict with the entry being added are\r
+        automatically removed with warning messages.\r
+</simpara>\r
+</listitem>\r
+</varlistentry>\r
+<varlistentry>\r
+<term>\r
+--stdin\r
+</term>\r
+<listitem>\r
+<simpara>\r
+        Instead of taking list of paths from the command line,\r
+        read list of paths from the standard input.  Paths are\r
+        separated by LF (i.e. one path per line) by default.\r
+</simpara>\r
+</listitem>\r
+</varlistentry>\r
+<varlistentry>\r
+<term>\r
+--verbose\r
+</term>\r
+<listitem>\r
+<simpara>\r
+        Report what is being added and removed from index.\r
+</simpara>\r
+</listitem>\r
+</varlistentry>\r
+<varlistentry>\r
+<term>\r
+-z\r
+</term>\r
+<listitem>\r
+<simpara>\r
+        Only meaningful with <literal>--stdin</literal>; paths are separated with\r
+        NUL character instead of LF.\r
+</simpara>\r
+</listitem>\r
+</varlistentry>\r
+<varlistentry>\r
+<term>\r
+--\r
+</term>\r
+<listitem>\r
+<simpara>\r
+        Do not interpret any more arguments as options.\r
+</simpara>\r
+</listitem>\r
+</varlistentry>\r
+<varlistentry>\r
+<term>\r
+&lt;file&gt;\r
+</term>\r
+<listitem>\r
+<simpara>\r
+        Files to act on.\r
+        Note that files beginning with <emphasis>.</emphasis> are discarded. This includes\r
+        <literal>./file</literal> and <literal>dir/./file</literal>. If you don&#8217;t want this, then use\r
+        cleaner names.\r
+        The same applies to directories ending <emphasis>/</emphasis> and paths with <emphasis>//</emphasis>\r
+</simpara>\r
+</listitem>\r
+</varlistentry>\r
+</variablelist>\r
+</simplesect>\r
+<simplesect id="_using_refresh">\r
+<title>Using --refresh</title>\r
+<simpara><emphasis>--refresh</emphasis> does not calculate a new sha1 file or bring the index\r
+up-to-date for mode/content changes. But what it <emphasis role="strong">does</emphasis> do is to\r
+"re-match" the stat information of a file with the index, so that you\r
+can refresh the index for a file that hasn&#8217;t been changed but where\r
+the stat entry is out of date.</simpara>\r
+<simpara>For example, you&#8217;d want to do this after doing a <emphasis>git-read-tree</emphasis>, to link\r
+up the stat index details with the proper files.</simpara>\r
+</simplesect>\r
+<simplesect id="_using_cacheinfo_or_info_only">\r
+<title>Using --cacheinfo or --info-only</title>\r
+<simpara><emphasis>--cacheinfo</emphasis> is used to register a file that is not in the\r
+current working directory.  This is useful for minimum-checkout\r
+merging.</simpara>\r
+<simpara>To pretend you have a file with mode and sha1 at path, say:</simpara>\r
+<literallayout>$ git update-index --cacheinfo mode sha1 path</literallayout>\r
+<simpara><emphasis>--info-only</emphasis> is used to register files without placing them in the object\r
+database.  This is useful for status-only repositories.</simpara>\r
+<simpara>Both <emphasis>--cacheinfo</emphasis> and <emphasis>--info-only</emphasis> behave similarly: the index is updated\r
+but the object database isn&#8217;t.  <emphasis>--cacheinfo</emphasis> is useful when the object is\r
+in the database but the file isn&#8217;t available locally.  <emphasis>--info-only</emphasis> is\r
+useful when the file is available, but you do not wish to update the\r
+object database.</simpara>\r
+</simplesect>\r
+<simplesect id="_using_index_info">\r
+<title>Using --index-info</title>\r
+<simpara><literal>--index-info</literal> is a more powerful mechanism that lets you feed\r
+multiple entry definitions from the standard input, and designed\r
+specifically for scripts.  It can take inputs of three formats:</simpara>\r
+<orderedlist numeration="arabic">\r
+<listitem>\r
+<simpara>\r
+mode         SP sha1          TAB path\r
+</simpara>\r
+<simpara>The first format is what "git-apply --index-info"\r
+reports, and used to reconstruct a partial tree\r
+that is used for phony merge base tree when falling\r
+back on 3-way merge.</simpara>\r
+</listitem>\r
+<listitem>\r
+<simpara>\r
+mode SP type SP sha1          TAB path\r
+</simpara>\r
+<simpara>The second format is to stuff <emphasis>git-ls-tree</emphasis> output\r
+into the index file.</simpara>\r
+</listitem>\r
+<listitem>\r
+<simpara>\r
+mode         SP sha1 SP stage TAB path\r
+</simpara>\r
+<simpara>This format is to put higher order stages into the\r
+index file and matches <emphasis>git-ls-files --stage</emphasis> output.</simpara>\r
+</listitem>\r
+</orderedlist>\r
+<simpara>To place a higher stage entry to the index, the path should\r
+first be removed by feeding a mode=0 entry for the path, and\r
+then feeding necessary input lines in the third format.</simpara>\r
+<simpara>For example, starting with this index:</simpara>\r
+<literallayout>$ git ls-files -s\r
+100644 8a1218a1024a212bb3db30becd860315f9f3ac52 0       frotz</literallayout>\r
+<simpara>you can feed the following input to <literal>--index-info</literal>:</simpara>\r
+<literallayout>$ git update-index --index-info\r
+0 0000000000000000000000000000000000000000      frotz\r
+100644 8a1218a1024a212bb3db30becd860315f9f3ac52 1       frotz\r
+100755 8a1218a1024a212bb3db30becd860315f9f3ac52 2       frotz</literallayout>\r
+<simpara>The first line of the input feeds 0 as the mode to remove the\r
+path; the SHA1 does not matter as long as it is well formatted.\r
+Then the second and third line feeds stage 1 and stage 2 entries\r
+for that path.  After the above, we would end up with this:</simpara>\r
+<literallayout>$ git ls-files -s\r
+100644 8a1218a1024a212bb3db30becd860315f9f3ac52 1       frotz\r
+100755 8a1218a1024a212bb3db30becd860315f9f3ac52 2       frotz</literallayout>\r
+</simplesect>\r
+<simplesect id="_using_8220_assume_unchanged_8221_bit">\r
+<title>Using &#8220;assume unchanged&#8221; bit</title>\r
+<simpara>Many operations in git depend on your filesystem to have an\r
+efficient <literal>lstat(2)</literal> implementation, so that <literal>st_mtime</literal>\r
+information for working tree files can be cheaply checked to see\r
+if the file contents have changed from the version recorded in\r
+the index file.  Unfortunately, some filesystems have\r
+inefficient <literal>lstat(2)</literal>.  If your filesystem is one of them, you\r
+can set "assume unchanged" bit to paths you have not changed to\r
+cause git not to do this check.  Note that setting this bit on a\r
+path does not mean git will check the contents of the file to\r
+see if it has changed&#8201;&#8212;&#8201;it makes git to omit any checking and\r
+assume it has <emphasis role="strong">not</emphasis> changed.  When you make changes to working\r
+tree files, you have to explicitly tell git about it by dropping\r
+"assume unchanged" bit, either before or after you modify them.</simpara>\r
+<simpara>In order to set "assume unchanged" bit, use <literal>--assume-unchanged</literal>\r
+option.  To unset, use <literal>--no-assume-unchanged</literal>.</simpara>\r
+<simpara>The command looks at <literal>core.ignorestat</literal> configuration variable.  When\r
+this is true, paths updated with <literal>git update-index paths&#8230;</literal> and\r
+paths updated with other git commands that update both index and\r
+working tree (e.g. <emphasis>git-apply --index</emphasis>, <emphasis>git-checkout-index -u</emphasis>,\r
+and <emphasis>git-read-tree -u</emphasis>) are automatically marked as "assume\r
+unchanged".  Note that "assume unchanged" bit is <emphasis role="strong">not</emphasis> set if\r
+<literal>git update-index --refresh</literal> finds the working tree file matches\r
+the index (use <literal>git update-index --really-refresh</literal> if you want\r
+to mark them as "assume unchanged").</simpara>\r
+</simplesect>\r
+<simplesect id="_examples">\r
+<title>Examples</title>\r
+<simpara>To update and refresh only the files already checked out:</simpara>\r
+<literallayout>$ git checkout-index -n -f -a &amp;&amp; git update-index --ignore-missing --refresh</literallayout>\r
+<variablelist>\r
+<varlistentry>\r
+<term>\r
+On an inefficient filesystem with <literal>core.ignorestat</literal> set\r
+</term>\r
+<listitem>\r
+<literallayout>$ git update-index --really-refresh              <co id="CO1-1"/>\r
+$ git update-index --no-assume-unchanged foo.c   <co id="CO1-2"/>\r
+$ git diff --name-only                           <co id="CO1-3"/>\r
+$ edit foo.c\r
+$ git diff --name-only                           <co id="CO1-4"/>\r
+M foo.c\r
+$ git update-index foo.c                         <co id="CO1-5"/>\r
+$ git diff --name-only                           <co id="CO1-6"/>\r
+$ edit foo.c\r
+$ git diff --name-only                           <co id="CO1-7"/>\r
+$ git update-index --no-assume-unchanged foo.c   <co id="CO1-8"/>\r
+$ git diff --name-only                           <co id="CO1-9"/>\r
+M foo.c</literallayout>\r
+<calloutlist>\r
+<callout arearefs="CO1-1">\r
+<simpara>\r
+forces lstat(2) to set "assume unchanged" bits for paths that match index.\r
+</simpara>\r
+</callout>\r
+<callout arearefs="CO1-2">\r
+<simpara>\r
+mark the path to be edited.\r
+</simpara>\r
+</callout>\r
+<callout arearefs="CO1-3">\r
+<simpara>\r
+this does lstat(2) and finds index matches the path.\r
+</simpara>\r
+</callout>\r
+<callout arearefs="CO1-4">\r
+<simpara>\r
+this does lstat(2) and finds index does <emphasis role="strong">not</emphasis> match the path.\r
+</simpara>\r
+</callout>\r
+<callout arearefs="CO1-5">\r
+<simpara>\r
+registering the new version to index sets "assume unchanged" bit.\r
+</simpara>\r
+</callout>\r
+<callout arearefs="CO1-6">\r
+<simpara>\r
+and it is assumed unchanged.\r
+</simpara>\r
+</callout>\r
+<callout arearefs="CO1-7">\r
+<simpara>\r
+even after you edit it.\r
+</simpara>\r
+</callout>\r
+<callout arearefs="CO1-8">\r
+<simpara>\r
+you can tell about the change after the fact.\r
+</simpara>\r
+</callout>\r
+<callout arearefs="CO1-9">\r
+<simpara>\r
+now it checks with lstat(2) and finds it has been changed.\r
+</simpara>\r
+</callout>\r
+</calloutlist>\r
+</listitem>\r
+</varlistentry>\r
+</variablelist>\r
+</simplesect>\r
+<simplesect id="_configuration">\r
+<title>Configuration</title>\r
+<simpara>The command honors <literal>core.filemode</literal> configuration variable.  If\r
+your repository is on an filesystem whose executable bits are\r
+unreliable, this should be set to <emphasis>false</emphasis> (see <xref linkend="git-config(1)"/>).\r
+This causes the command to ignore differences in file modes recorded\r
+in the index and the file mode on the filesystem if they differ only on\r
+executable bit.   On such an unfortunate filesystem, you may\r
+need to use <emphasis>git-update-index --chmod=</emphasis>.</simpara>\r
+<simpara>Quite similarly, if <literal>core.symlinks</literal> configuration variable is set\r
+to <emphasis>false</emphasis> (see <xref linkend="git-config(1)"/>), symbolic links are checked out\r
+as plain files, and this command does not modify a recorded file mode\r
+from symbolic link to regular file.</simpara>\r
+<simpara>The command looks at <literal>core.ignorestat</literal> configuration variable.  See\r
+<emphasis>Using "assume unchanged" bit</emphasis> section above.</simpara>\r
+<simpara>The command also looks at <literal>core.trustctime</literal> configuration variable.\r
+It can be useful when the inode change time is regularly modified by\r
+something outside Git (file system crawlers and backup systems use\r
+ctime for marking files processed) (see <xref linkend="git-config(1)"/>).</simpara>\r
+</simplesect>\r
+<simplesect id="_see_also">\r
+<title>SEE ALSO</title>\r
+<simpara><xref linkend="git-config(1)"/>,\r
+<xref linkend="git-add(1)"/></simpara>\r
+</simplesect>\r
+<simplesect id="_author">\r
+<title>Author</title>\r
+<simpara>Written by Linus Torvalds &lt;<ulink url="mailto:torvalds@osdl.org">torvalds@osdl.org</ulink>&gt;</simpara>\r
+</simplesect>\r
+<simplesect id="_documentation">\r
+<title>Documentation</title>\r
+<simpara>Documentation by David Greaves, Junio C Hamano and the git-list &lt;<ulink url="mailto:git@vger.kernel.org">git@vger.kernel.org</ulink>&gt;.</simpara>\r
+</simplesect>\r
+<simplesect id="_git">\r
+<title>GIT</title>\r
+<simpara>Part of the <xref linkend="git(1)"/> suite</simpara>\r
+</simplesect>\r
+</article>\r