{
    "mode": "man",
    "parameter": "git-update-index",
    "section": "1",
    "url": "https://www.chedong.com/phpMan.php/man/git-update-index/1/json",
    "generated": "2026-06-10T16:22:19Z",
    "synopsis": "git update-index\n[--add] [--remove | --force-remove] [--replace]\n[--refresh] [-q] [--unmerged] [--ignore-missing]\n[(--cacheinfo <mode>,<object>,<file>)...]\n[--chmod=(+|-)x]\n[--[no-]assume-unchanged]\n[--[no-]skip-worktree]\n[--[no-]ignore-skip-worktree-entries]\n[--[no-]fsmonitor-valid]\n[--ignore-submodules]\n[--[no-]split-index]\n[--[no-|test-|force-]untracked-cache]\n[--[no-]fsmonitor]\n[--really-refresh] [--unresolve] [--again | -g]\n[--info-only] [--index-info]\n[-z] [--stdin] [--index-version <n>]\n[--verbose]\n[--] [<file>...]",
    "sections": {
        "NAME": {
            "content": "git-update-index - Register file contents in the working tree to the index\n",
            "subsections": []
        },
        "SYNOPSIS": {
            "content": "git update-index\n[--add] [--remove | --force-remove] [--replace]\n[--refresh] [-q] [--unmerged] [--ignore-missing]\n[(--cacheinfo <mode>,<object>,<file>)...]\n[--chmod=(+|-)x]\n[--[no-]assume-unchanged]\n[--[no-]skip-worktree]\n[--[no-]ignore-skip-worktree-entries]\n[--[no-]fsmonitor-valid]\n[--ignore-submodules]\n[--[no-]split-index]\n[--[no-|test-|force-]untracked-cache]\n[--[no-]fsmonitor]\n[--really-refresh] [--unresolve] [--again | -g]\n[--info-only] [--index-info]\n[-z] [--stdin] [--index-version <n>]\n[--verbose]\n[--] [<file>...]\n\n",
            "subsections": []
        },
        "DESCRIPTION": {
            "content": "Modifies the index. Each file mentioned is updated into the index and any unmerged or needs\nupdating state is cleared.\n\nSee also git-add(1) for a more user-friendly way to do some of the most common operations on\nthe index.\n\nThe way git update-index handles files it is told about can be modified using the various\noptions:\n",
            "subsections": []
        },
        "OPTIONS": {
            "content": "",
            "subsections": [
                {
                    "name": "--add",
                    "content": "If a specified file isn’t in the index already then it’s added. Default behaviour is to\nignore new files.\n",
                    "long": "--add"
                },
                {
                    "name": "--remove",
                    "content": "If a specified file is in the index but is missing then it’s removed. Default behavior is\nto ignore removed file.\n",
                    "long": "--remove"
                },
                {
                    "name": "--refresh",
                    "content": "Looks at the current index and checks to see if merges or updates are needed by checking\nstat() information.\n",
                    "long": "--refresh"
                },
                {
                    "name": "-q",
                    "content": "Quiet. If --refresh finds that the index needs an update, the default behavior is to\nerror out. This option makes git update-index continue anyway.\n",
                    "flag": "-q"
                },
                {
                    "name": "--ignore-submodules",
                    "content": "Do not try to update submodules. This option is only respected when passed before\n--refresh.\n",
                    "long": "--ignore-submodules"
                },
                {
                    "name": "--unmerged",
                    "content": "If --refresh finds unmerged changes in the index, the default behavior is to error out.\nThis option makes git update-index continue anyway.\n",
                    "long": "--unmerged"
                },
                {
                    "name": "--ignore-missing",
                    "content": "Ignores missing files during a --refresh\n\n--cacheinfo <mode>,<object>,<path>, --cacheinfo <mode> <object> <path>\nDirectly insert the specified info into the index. For backward compatibility, you can\nalso give these three arguments as three separate parameters, but new users are\nencouraged to use a single-parameter form.\n",
                    "long": "--ignore-missing"
                },
                {
                    "name": "--index-info",
                    "content": "Read index information from stdin.\n\n--chmod=(+|-)x\nSet the execute permissions on the updated files.\n\n--[no-]assume-unchanged\nWhen this flag is specified, the object names recorded for the paths are not updated.\nInstead, this option sets/unsets the \"assume unchanged\" bit for the paths. When the\n\"assume unchanged\" bit is on, the user promises not to change the file and allows Git to\nassume that the working tree file matches what is recorded in the index. If you want to\nchange the working tree file, you need to unset the bit to tell Git. This is sometimes\nhelpful when working with a big project on a filesystem that has very slow lstat(2)\nsystem call (e.g. cifs).\n\nGit will fail (gracefully) in case it needs to modify this file in the index e.g. when\nmerging in a commit; thus, in case the assumed-untracked file is changed upstream, you\nwill need to handle the situation manually.\n",
                    "long": "--index-info"
                },
                {
                    "name": "--really-refresh",
                    "content": "Like --refresh, but checks stat information unconditionally, without regard to the\n\"assume unchanged\" setting.\n\n--[no-]skip-worktree\nWhen one of these flags is specified, the object name recorded for the paths are not\nupdated. Instead, these options set and unset the \"skip-worktree\" bit for the paths. See\nsection \"Skip-worktree bit\" below for more information.\n\n--[no-]ignore-skip-worktree-entries\nDo not remove skip-worktree (AKA \"index-only\") entries even when the --remove option was\nspecified.\n\n--[no-]fsmonitor-valid\nWhen one of these flags is specified, the object name recorded for the paths are not\nupdated. Instead, these options set and unset the \"fsmonitor valid\" bit for the paths.\nSee section \"File System Monitor\" below for more information.\n",
                    "long": "--really-refresh"
                },
                {
                    "name": "-g, --again",
                    "content": "Runs git update-index itself on the paths whose index entries are different from those\nfrom the HEAD commit.\n",
                    "flag": "-g",
                    "long": "--again"
                },
                {
                    "name": "--unresolve",
                    "content": "Restores the unmerged or needs updating state of a file during a merge if it was cleared\nby accident.\n",
                    "long": "--unresolve"
                },
                {
                    "name": "--info-only",
                    "content": "Do not create objects in the object database for all <file> arguments that follow this\nflag; just insert their object IDs into the index.\n",
                    "long": "--info-only"
                },
                {
                    "name": "--force-remove",
                    "content": "Remove the file from the index even when the working directory still has such a file.\n(Implies --remove.)\n",
                    "long": "--force-remove"
                },
                {
                    "name": "--replace",
                    "content": "By default, when a file path exists in the index, git update-index refuses an attempt to\nadd path/file. Similarly if a file path/file exists, a file path cannot be added. With\n--replace flag, existing entries that conflict with the entry being added are\nautomatically removed with warning messages.\n",
                    "long": "--replace"
                },
                {
                    "name": "--stdin",
                    "content": "Instead of taking list of paths from the command line, read list of paths from the\nstandard input. Paths are separated by LF (i.e. one path per line) by default.\n",
                    "long": "--stdin"
                },
                {
                    "name": "--verbose",
                    "content": "Report what is being added and removed from index.\n",
                    "long": "--verbose"
                },
                {
                    "name": "--index-version <n>",
                    "content": "Write the resulting index out in the named on-disk format version. Supported versions are\n2, 3 and 4. The current default version is 2 or 3, depending on whether extra features\nare used, such as git add -N.\n\nVersion 4 performs a simple pathname compression that reduces index size by 30%-50% on\nlarge repositories, which results in faster load time. Version 4 is relatively young\n(first released in 1.8.0 in October 2012). Other Git implementations such as JGit and\nlibgit2 may not support it yet.\n",
                    "long": "--index-version",
                    "arg": "<n>"
                },
                {
                    "name": "-z",
                    "content": "Only meaningful with --stdin or --index-info; paths are separated with NUL character\ninstead of LF.\n",
                    "flag": "-z"
                },
                {
                    "name": "--split-index, --no-split-index",
                    "content": "Enable or disable split index mode. If split-index mode is already enabled and\n--split-index is given again, all changes in $GITDIR/index are pushed back to the shared\nindex file.\n\nThese options take effect whatever the value of the core.splitIndex configuration\nvariable (see git-config(1)). But a warning is emitted when the change goes against the\nconfigured value, as the configured value will take effect next time the index is read\nand this will remove the intended effect of the option.\n",
                    "long": "--no-split-index"
                },
                {
                    "name": "--untracked-cache, --no-untracked-cache",
                    "content": "Enable or disable untracked cache feature. Please use --test-untracked-cache before\nenabling it.\n\nThese options take effect whatever the value of the core.untrackedCache configuration\nvariable (see git-config(1)). But a warning is emitted when the change goes against the\nconfigured value, as the configured value will take effect next time the index is read\nand this will remove the intended effect of the option.\n",
                    "long": "--no-untracked-cache"
                },
                {
                    "name": "--test-untracked-cache",
                    "content": "Only perform tests on the working directory to make sure untracked cache can be used. You\nhave to manually enable untracked cache using --untracked-cache or\n--force-untracked-cache or the core.untrackedCache configuration variable afterwards if\nyou really want to use it. If a test fails the exit code is 1 and a message explains what\nis not working as needed, otherwise the exit code is 0 and OK is printed.\n",
                    "long": "--test-untracked-cache"
                },
                {
                    "name": "--force-untracked-cache",
                    "content": "Same as --untracked-cache. Provided for backwards compatibility with older versions of\nGit where --untracked-cache used to imply --test-untracked-cache but this option would\nenable the extension unconditionally.\n",
                    "long": "--force-untracked-cache"
                },
                {
                    "name": "--fsmonitor, --no-fsmonitor",
                    "content": "Enable or disable files system monitor feature. These options take effect whatever the\nvalue of the core.fsmonitor configuration variable (see git-config(1)). But a warning is\nemitted when the change goes against the configured value, as the configured value will\ntake effect next time the index is read and this will remove the intended effect of the\noption.\n\n--\nDo not interpret any more arguments as options.\n\n<file>\nFiles to act on. Note that files beginning with .  are discarded. This includes ./file\nand dir/./file. If you don’t want this, then use cleaner names. The same applies to\ndirectories ending / and paths with //\n",
                    "long": "--no-fsmonitor"
                }
            ]
        },
        "USING --REFRESH": {
            "content": "--refresh does not calculate a new sha1 file or bring the index up to date for mode/content\nchanges. But what it does do is to \"re-match\" the stat information of a file with the index,\nso that you can refresh the index for a file that hasn’t been changed but where the stat\nentry is out of date.\n\nFor example, you’d want to do this after doing a git read-tree, to link up the stat index\ndetails with the proper files.\n",
            "subsections": []
        },
        "USING --CACHEINFO OR --INFO-ONLY": {
            "content": "--cacheinfo is used to register a file that is not in the current working directory. This is\nuseful for minimum-checkout merging.\n\nTo pretend you have a file at path with mode and sha1, say:\n\n$ git update-index --add --cacheinfo <mode>,<sha1>,<path>\n\n\n--info-only is used to register files without placing them in the object database. This is\nuseful for status-only repositories.\n\nBoth --cacheinfo and --info-only behave similarly: the index is updated but the object\ndatabase isn’t. --cacheinfo is useful when the object is in the database but the file isn’t\navailable locally. --info-only is useful when the file is available, but you do not wish to\nupdate the object database.\n",
            "subsections": []
        },
        "USING --INDEX-INFO": {
            "content": "--index-info is a more powerful mechanism that lets you feed multiple entry definitions from\nthe standard input, and designed specifically for scripts. It can take inputs of three\nformats:\n\n1. mode SP type SP sha1 TAB path\n\nThis format is to stuff git ls-tree output into the index.\n\n2. mode SP sha1 SP stage TAB path\n\nThis format is to put higher order stages into the index file and matches git ls-files\n--stage output.\n\n3. mode SP sha1 TAB path\n\nThis format is no longer produced by any Git command, but is and will continue to be\nsupported by update-index --index-info.\n\nTo place a higher stage entry to the index, the path should first be removed by feeding a\nmode=0 entry for the path, and then feeding necessary input lines in the third format.\n\nFor example, starting with this index:\n\n$ git ls-files -s\n100644 8a1218a1024a212bb3db30becd860315f9f3ac52 0       frotz\n\n\nyou can feed the following input to --index-info:\n\n$ git update-index --index-info\n0 0000000000000000000000000000000000000000      frotz\n100644 8a1218a1024a212bb3db30becd860315f9f3ac52 1       frotz\n100755 8a1218a1024a212bb3db30becd860315f9f3ac52 2       frotz\n\n\nThe first line of the input feeds 0 as the mode to remove the path; the SHA-1 does not matter\nas long as it is well formatted. Then the second and third line feeds stage 1 and stage 2\nentries for that path. After the above, we would end up with this:\n\n$ git ls-files -s\n100644 8a1218a1024a212bb3db30becd860315f9f3ac52 1       frotz\n100755 8a1218a1024a212bb3db30becd860315f9f3ac52 2       frotz\n\n\nUSING ““ASSUME UNCHANGED”” BIT\nMany operations in Git depend on your filesystem to have an efficient lstat(2)\nimplementation, so that stmtime information for working tree files can be cheaply checked to\nsee if the file contents have changed from the version recorded in the index file.\nUnfortunately, some filesystems have inefficient lstat(2). If your filesystem is one of them,\nyou can set \"assume unchanged\" bit to paths you have not changed to cause Git not to do this\ncheck. Note that setting this bit on a path does not mean Git will check the contents of the\nfile to see if it has changed — it makes Git to omit any checking and assume it has not\nchanged. When you make changes to working tree files, you have to explicitly tell Git about\nit by dropping \"assume unchanged\" bit, either before or after you modify them.\n\nIn order to set \"assume unchanged\" bit, use --assume-unchanged option. To unset, use\n--no-assume-unchanged. To see which files have the \"assume unchanged\" bit set, use git\nls-files -v (see git-ls-files(1)).\n\nThe command looks at core.ignorestat configuration variable. When this is true, paths updated\nwith git update-index paths... and paths updated with other Git commands that update both\nindex and working tree (e.g. git apply --index, git checkout-index -u, and git read-tree -u)\nare automatically marked as \"assume unchanged\". Note that \"assume unchanged\" bit is not set\nif git update-index --refresh finds the working tree file matches the index (use git\nupdate-index --really-refresh if you want to mark them as \"assume unchanged\").\n",
            "subsections": []
        },
        "EXAMPLES": {
            "content": "To update and refresh only the files already checked out:\n\n$ git checkout-index -n -f -a && git update-index --ignore-missing --refresh\n\n\n\nOn an inefficient filesystem with core.ignorestat set\n\n$ git update-index --really-refresh              (1)\n$ git update-index --no-assume-unchanged foo.c   (2)\n$ git diff --name-only                           (3)\n$ edit foo.c\n$ git diff --name-only                           (4)\nM foo.c\n$ git update-index foo.c                         (5)\n$ git diff --name-only                           (6)\n$ edit foo.c\n$ git diff --name-only                           (7)\n$ git update-index --no-assume-unchanged foo.c   (8)\n$ git diff --name-only                           (9)\nM foo.c\n\n1. forces lstat(2) to set \"assume unchanged\" bits for paths that match index.\n2. mark the path to be edited.\n3. this does lstat(2) and finds index matches the path.\n4. this does lstat(2) and finds index does not match the path.\n5. registering the new version to index sets \"assume unchanged\" bit.\n6. and it is assumed unchanged.\n7. even after you edit it.\n8. you can tell about the change after the fact.\n9. now it checks with lstat(2) and finds it has been changed.\n",
            "subsections": []
        },
        "SKIP-WORKTREE BIT": {
            "content": "Skip-worktree bit can be defined in one (long) sentence: When reading an entry, if it is\nmarked as skip-worktree, then Git pretends its working directory version is up to date and\nread the index version instead.\n\nTo elaborate, \"reading\" means checking for file existence, reading file attributes or file\ncontent. The working directory version may be present or absent. If present, its content may\nmatch against the index version or not. Writing is not affected by this bit, content safety\nis still first priority. Note that Git can update working directory file, that is marked\nskip-worktree, if it is safe to do so (i.e. working directory version matches index version)\n\nAlthough this bit looks similar to assume-unchanged bit, its goal is different from\nassume-unchanged bit’s. Skip-worktree also takes precedence over assume-unchanged bit when\nboth are set.\n",
            "subsections": []
        },
        "SPLIT INDEX": {
            "content": "This mode is designed for repositories with very large indexes, and aims at reducing the time\nit takes to repeatedly write these indexes.\n\nIn this mode, the index is split into two files, $GITDIR/index and\n$GITDIR/sharedindex.<SHA-1>. Changes are accumulated in $GITDIR/index, the split index,\nwhile the shared index file contains all index entries and stays unchanged.\n\nAll changes in the split index are pushed back to the shared index file when the number of\nentries in the split index reaches a level specified by the splitIndex.maxPercentChange\nconfig variable (see git-config(1)).\n\nEach time a new shared index file is created, the old shared index files are deleted if their\nmodification time is older than what is specified by the splitIndex.sharedIndexExpire config\nvariable (see git-config(1)).\n\nTo avoid deleting a shared index file that is still used, its modification time is updated to\nthe current time every time a new split index based on the shared index file is either\ncreated or read from.\n",
            "subsections": []
        },
        "UNTRACKED CACHE": {
            "content": "This cache is meant to speed up commands that involve determining untracked files such as git\nstatus.\n\nThis feature works by recording the mtime of the working tree directories and then omitting\nreading directories and stat calls against files in those directories whose mtime hasn’t\nchanged. For this to work the underlying operating system and file system must change the\nstmtime field of directories if files in the directory are added, modified or deleted.\n\nYou can test whether the filesystem supports that with the --test-untracked-cache option. The\n--untracked-cache option used to implicitly perform that test in older versions of Git, but\nthat’s no longer the case.\n\nIf you want to enable (or disable) this feature, it is easier to use the core.untrackedCache\nconfiguration variable (see git-config(1)) than using the --untracked-cache option to git\nupdate-index in each repository, especially if you want to do so across all repositories you\nuse, because you can set the configuration variable to true (or false) in your\n$HOME/.gitconfig just once and have it affect all repositories you touch.\n\nWhen the core.untrackedCache configuration variable is changed, the untracked cache is added\nto or removed from the index the next time a command reads the index; while when\n--[no-|force-]untracked-cache are used, the untracked cache is immediately added to or\nremoved from the index.\n\nBefore 2.17, the untracked cache had a bug where replacing a directory with a symlink to\nanother directory could cause it to incorrectly show files tracked by git as untracked. See\nthe \"status: add a failing test showing a core.untrackedCache bug\" commit to git.git. A\nworkaround for that is (and this might work for other undiscovered bugs in the future):\n\n$ git -c core.untrackedCache=false status\n\n\nThis bug has also been shown to affect non-symlink cases of replacing a directory with a file\nwhen it comes to the internal structures of the untracked cache, but no case has been\nreported where this resulted in wrong \"git status\" output.\n\nThere are also cases where existing indexes written by git versions before 2.17 will\nreference directories that don’t exist anymore, potentially causing many \"could not open\ndirectory\" warnings to be printed on \"git status\". These are new warnings for existing issues\nthat were previously silently discarded.\n\nAs with the bug described above the solution is to one-off do a \"git status\" run with\ncore.untrackedCache=false to flush out the leftover bad data.\n",
            "subsections": []
        },
        "FILE SYSTEM MONITOR": {
            "content": "This feature is intended to speed up git operations for repos that have large working\ndirectories.\n\nIt enables git to work together with a file system monitor (see the \"fsmonitor-watchman\"\nsection of githooks(5)) that can inform it as to what files have been modified. This enables\ngit to avoid having to lstat() every file to find modified files.\n\nWhen used in conjunction with the untracked cache, it can further improve performance by\navoiding the cost of scanning the entire working directory looking for new files.\n\nIf you want to enable (or disable) this feature, it is easier to use the core.fsmonitor\nconfiguration variable (see git-config(1)) than using the --fsmonitor option to git\nupdate-index in each repository, especially if you want to do so across all repositories you\nuse, because you can set the configuration variable in your $HOME/.gitconfig just once and\nhave it affect all repositories you touch.\n\nWhen the core.fsmonitor configuration variable is changed, the file system monitor is added\nto or removed from the index the next time a command reads the index. When --[no-]fsmonitor\nare used, the file system monitor is immediately added to or removed from the index.\n",
            "subsections": []
        },
        "CONFIGURATION": {
            "content": "The command honors core.filemode configuration variable. If your repository is on a\nfilesystem whose executable bits are unreliable, this should be set to false (see git-\nconfig(1)). This causes the command to ignore differences in file modes recorded in the index\nand the file mode on the filesystem if they differ only on executable bit. On such an\nunfortunate filesystem, you may need to use git update-index --chmod=.\n\nQuite similarly, if core.symlinks configuration variable is set to false (see git-config(1)),\nsymbolic links are checked out as plain files, and this command does not modify a recorded\nfile mode from symbolic link to regular file.\n\nThe command looks at core.ignorestat configuration variable. See Using \"assume unchanged\" bit\nsection above.\n\nThe command also looks at core.trustctime configuration variable. It can be useful when the\ninode change time is regularly modified by something outside Git (file system crawlers and\nbackup systems use ctime for marking files processed) (see git-config(1)).\n\nThe untracked cache extension can be enabled by the core.untrackedCache configuration\nvariable (see git-config(1)).\n",
            "subsections": []
        },
        "NOTES": {
            "content": "Users often try to use the assume-unchanged and skip-worktree bits to tell Git to ignore\nchanges to files that are tracked. This does not work as expected, since Git may still check\nworking tree files against the index when performing certain operations. In general, Git does\nnot provide a way to ignore changes to tracked files, so alternate solutions are recommended.\n\nFor example, if the file you want to change is some sort of config file, the repository can\ninclude a sample config file that can then be copied into the ignored name and modified. The\nrepository can even include a script to treat the sample file as a template, modifying and\ncopying it automatically.\n",
            "subsections": []
        },
        "SEE ALSO": {
            "content": "git-config(1), git-add(1), git-ls-files(1)\n",
            "subsections": []
        },
        "GIT": {
            "content": "Part of the git(1) suite\n\n\n\nGit 2.34.1                                   02/26/2026                          GIT-UPDATE-INDEX(1)",
            "subsections": []
        }
    },
    "summary": "git-update-index - Register file contents in the working tree to the index",
    "flags": [
        {
            "flag": "",
            "long": "--add",
            "arg": null,
            "description": "If a specified file isn’t in the index already then it’s added. Default behaviour is to ignore new files."
        },
        {
            "flag": "",
            "long": "--remove",
            "arg": null,
            "description": "If a specified file is in the index but is missing then it’s removed. Default behavior is to ignore removed file."
        },
        {
            "flag": "",
            "long": "--refresh",
            "arg": null,
            "description": "Looks at the current index and checks to see if merges or updates are needed by checking stat() information."
        },
        {
            "flag": "-q",
            "long": null,
            "arg": null,
            "description": "Quiet. If --refresh finds that the index needs an update, the default behavior is to error out. This option makes git update-index continue anyway."
        },
        {
            "flag": "",
            "long": "--ignore-submodules",
            "arg": null,
            "description": "Do not try to update submodules. This option is only respected when passed before --refresh."
        },
        {
            "flag": "",
            "long": "--unmerged",
            "arg": null,
            "description": "If --refresh finds unmerged changes in the index, the default behavior is to error out. This option makes git update-index continue anyway."
        },
        {
            "flag": "",
            "long": "--ignore-missing",
            "arg": null,
            "description": "Ignores missing files during a --refresh --cacheinfo <mode>,<object>,<path>, --cacheinfo <mode> <object> <path> Directly insert the specified info into the index. For backward compatibility, you can also give these three arguments as three separate parameters, but new users are encouraged to use a single-parameter form."
        },
        {
            "flag": "",
            "long": "--index-info",
            "arg": null,
            "description": "Read index information from stdin. --chmod=(+|-)x Set the execute permissions on the updated files. --[no-]assume-unchanged When this flag is specified, the object names recorded for the paths are not updated. Instead, this option sets/unsets the \"assume unchanged\" bit for the paths. When the \"assume unchanged\" bit is on, the user promises not to change the file and allows Git to assume that the working tree file matches what is recorded in the index. If you want to change the working tree file, you need to unset the bit to tell Git. This is sometimes helpful when working with a big project on a filesystem that has very slow lstat(2) system call (e.g. cifs). Git will fail (gracefully) in case it needs to modify this file in the index e.g. when merging in a commit; thus, in case the assumed-untracked file is changed upstream, you will need to handle the situation manually."
        },
        {
            "flag": "",
            "long": "--really-refresh",
            "arg": null,
            "description": "Like --refresh, but checks stat information unconditionally, without regard to the \"assume unchanged\" setting. --[no-]skip-worktree When one of these flags is specified, the object name recorded for the paths are not updated. Instead, these options set and unset the \"skip-worktree\" bit for the paths. See section \"Skip-worktree bit\" below for more information. --[no-]ignore-skip-worktree-entries Do not remove skip-worktree (AKA \"index-only\") entries even when the --remove option was specified. --[no-]fsmonitor-valid When one of these flags is specified, the object name recorded for the paths are not updated. Instead, these options set and unset the \"fsmonitor valid\" bit for the paths. See section \"File System Monitor\" below for more information."
        },
        {
            "flag": "-g",
            "long": "--again",
            "arg": null,
            "description": "Runs git update-index itself on the paths whose index entries are different from those from the HEAD commit."
        },
        {
            "flag": "",
            "long": "--unresolve",
            "arg": null,
            "description": "Restores the unmerged or needs updating state of a file during a merge if it was cleared by accident."
        },
        {
            "flag": "",
            "long": "--info-only",
            "arg": null,
            "description": "Do not create objects in the object database for all <file> arguments that follow this flag; just insert their object IDs into the index."
        },
        {
            "flag": "",
            "long": "--force-remove",
            "arg": null,
            "description": "Remove the file from the index even when the working directory still has such a file. (Implies --remove.)"
        },
        {
            "flag": "",
            "long": "--replace",
            "arg": null,
            "description": "By default, when a file path exists in the index, git update-index refuses an attempt to add path/file. Similarly if a file path/file exists, a file path cannot be added. With --replace flag, existing entries that conflict with the entry being added are automatically removed with warning messages."
        },
        {
            "flag": "",
            "long": "--stdin",
            "arg": null,
            "description": "Instead of taking list of paths from the command line, read list of paths from the standard input. Paths are separated by LF (i.e. one path per line) by default."
        },
        {
            "flag": "",
            "long": "--verbose",
            "arg": null,
            "description": "Report what is being added and removed from index."
        },
        {
            "flag": "",
            "long": "--index-version",
            "arg": "<n>",
            "description": "Write the resulting index out in the named on-disk format version. Supported versions are 2, 3 and 4. The current default version is 2 or 3, depending on whether extra features are used, such as git add -N. Version 4 performs a simple pathname compression that reduces index size by 30%-50% on large repositories, which results in faster load time. Version 4 is relatively young (first released in 1.8.0 in October 2012). Other Git implementations such as JGit and libgit2 may not support it yet."
        },
        {
            "flag": "-z",
            "long": null,
            "arg": null,
            "description": "Only meaningful with --stdin or --index-info; paths are separated with NUL character instead of LF."
        },
        {
            "flag": "",
            "long": "--no-split-index",
            "arg": null,
            "description": "Enable or disable split index mode. If split-index mode is already enabled and --split-index is given again, all changes in $GITDIR/index are pushed back to the shared index file. These options take effect whatever the value of the core.splitIndex configuration variable (see git-config(1)). But a warning is emitted when the change goes against the configured value, as the configured value will take effect next time the index is read and this will remove the intended effect of the option."
        },
        {
            "flag": "",
            "long": "--no-untracked-cache",
            "arg": null,
            "description": "Enable or disable untracked cache feature. Please use --test-untracked-cache before enabling it. These options take effect whatever the value of the core.untrackedCache configuration variable (see git-config(1)). But a warning is emitted when the change goes against the configured value, as the configured value will take effect next time the index is read and this will remove the intended effect of the option."
        },
        {
            "flag": "",
            "long": "--test-untracked-cache",
            "arg": null,
            "description": "Only perform tests on the working directory to make sure untracked cache can be used. You have to manually enable untracked cache using --untracked-cache or --force-untracked-cache or the core.untrackedCache configuration variable afterwards if you really want to use it. If a test fails the exit code is 1 and a message explains what is not working as needed, otherwise the exit code is 0 and OK is printed."
        },
        {
            "flag": "",
            "long": "--force-untracked-cache",
            "arg": null,
            "description": "Same as --untracked-cache. Provided for backwards compatibility with older versions of Git where --untracked-cache used to imply --test-untracked-cache but this option would enable the extension unconditionally."
        },
        {
            "flag": "",
            "long": "--no-fsmonitor",
            "arg": null,
            "description": "Enable or disable files system monitor feature. These options take effect whatever the value of the core.fsmonitor configuration variable (see git-config(1)). But a warning is emitted when the change goes against the configured value, as the configured value will take effect next time the index is read and this will remove the intended effect of the option. -- Do not interpret any more arguments as options. <file> Files to act on. Note that files beginning with . are discarded. This includes ./file and dir/./file. If you don’t want this, then use cleaner names. The same applies to directories ending / and paths with //"
        }
    ],
    "examples": [
        "To update and refresh only the files already checked out:",
        "$ git checkout-index -n -f -a && git update-index --ignore-missing --refresh",
        "On an inefficient filesystem with core.ignorestat set",
        "$ git update-index --really-refresh              (1)",
        "$ git update-index --no-assume-unchanged foo.c   (2)",
        "$ git diff --name-only                           (3)",
        "$ edit foo.c",
        "$ git diff --name-only                           (4)",
        "M foo.c",
        "$ git update-index foo.c                         (5)",
        "$ git diff --name-only                           (6)",
        "$ edit foo.c",
        "$ git diff --name-only                           (7)",
        "$ git update-index --no-assume-unchanged foo.c   (8)",
        "$ git diff --name-only                           (9)",
        "M foo.c",
        "1. forces lstat(2) to set \"assume unchanged\" bits for paths that match index.",
        "2. mark the path to be edited.",
        "3. this does lstat(2) and finds index matches the path.",
        "4. this does lstat(2) and finds index does not match the path.",
        "5. registering the new version to index sets \"assume unchanged\" bit.",
        "6. and it is assumed unchanged.",
        "7. even after you edit it.",
        "8. you can tell about the change after the fact.",
        "9. now it checks with lstat(2) and finds it has been changed."
    ],
    "see_also": [
        {
            "name": "git-config",
            "section": "1",
            "url": "https://www.chedong.com/phpMan.php/man/git-config/1/json"
        },
        {
            "name": "git-add",
            "section": "1",
            "url": "https://www.chedong.com/phpMan.php/man/git-add/1/json"
        },
        {
            "name": "git-ls-files",
            "section": "1",
            "url": "https://www.chedong.com/phpMan.php/man/git-ls-files/1/json"
        }
    ],
    "tldr": {
        "source": "official",
        "description": "Git command for manipulating the index.",
        "examples": [
            {
                "description": "Pretend that a modified file is unchanged (`git status` will not show this as changed)",
                "command": "git update-index --skip-worktree {{path/to/modified_file}}"
            }
        ]
    }
}