/usr/share/doc/git
NameSizeModeActions
contrib/-0755rm
howto/-0755rm
RelNotes/-0755rm
technical/-0755rm
blame-options.txt60010644editdlrm
cmds-ancillaryinterrogators.txt12940644editdlrm
cmds-ancillarymanipulators.txt7460644editdlrm
cmds-developerinterfaces.txt6780644editdlrm
cmds-foreignscminterface.txt3990644editdlrm
cmds-guide.txt8330644editdlrm
cmds-mainporcelain.txt30330644editdlrm
cmds-plumbinginterrogators.txt15390644editdlrm
cmds-plumbingmanipulators.txt14100644editdlrm
cmds-purehelpers.txt12680644editdlrm
cmds-synchelpers.txt4490644editdlrm
cmds-synchingrepositories.txt3970644editdlrm
cmds-userinterfaces.txt5070644editdlrm
CODE_OF_CONDUCT.md59890644editdlrm
config.txt180010644editdlrm
date-formats.txt11720644editdlrm
diff-format.txt65730644editdlrm
diff-generate-patch.txt72530644editdlrm
diff-options.txt324360644editdlrm
docbook-xsl.css45570644editdlrm
everyday.html169960644editdlrm
fetch-options.txt122810644editdlrm
fsck-msgids.txt41970644editdlrm
git-add.html403690644editdlrm
git-add.txt161640644editdlrm
git-am.html331610644editdlrm
git-am.txt93170644editdlrm
git-annotate.html283910644editdlrm
git-annotate.txt7710644editdlrm
git-apply.html334070644editdlrm
git-apply.txt109500644editdlrm
git-archive.html298560644editdlrm
git-archive.txt84910644editdlrm
git-bisect-lk2009.html812430644editdlrm
git-bisect-lk2009.txt496940644editdlrm
git-bisect.html405720644editdlrm
git-bisect.txt179050644editdlrm
git-blame.html425010644editdlrm
git-blame.txt87320644editdlrm
git-branch.html482530644editdlrm
git-branch.txt157480644editdlrm
git-bugreport.html205090644editdlrm
git-bugreport.txt24210644editdlrm
git-bundle.html332690644editdlrm
git-bundle.txt117030644editdlrm
git-cat-file.html386610644editdlrm
git-cat-file.txt136150644editdlrm
git-check-attr.html226330644editdlrm
git-check-attr.txt33900644editdlrm
git-check-ignore.html231350644editdlrm
git-check-ignore.txt41560644editdlrm
git-check-mailmap.html188160644editdlrm
git-check-mailmap.txt11080644editdlrm
git-check-ref-format.html240400644editdlrm
git-check-ref-format.txt50340644editdlrm
git-checkout-index.html253620644editdlrm
git-checkout-index.txt56690644editdlrm
git-checkout.html527190644editdlrm
git-checkout.txt223620644editdlrm
git-cherry-pick.html310650644editdlrm
git-cherry-pick.txt87640644editdlrm
git-cherry.html224230644editdlrm
git-cherry.txt36150644editdlrm
git-clean.html239810644editdlrm
git-clean.txt45230644editdlrm
git-clone.html443280644editdlrm
git-clone.txt147720644editdlrm
git-column.html233170644editdlrm
git-column.txt22010644editdlrm
git-commit-graph.html261470644editdlrm
git-commit-graph.txt59490644editdlrm
git-commit-tree.html266830644editdlrm
git-commit-tree.txt27100644editdlrm
git-commit.html571540644editdlrm
git-commit.txt215750644editdlrm
git-config.html4155400644editdlrm
git-config.txt197550644editdlrm
git-contacts.html207180644editdlrm
git-contacts.txt25840644editdlrm
git-count-objects.html189460644editdlrm
git-count-objects.txt13500644editdlrm
git-credential-cache--daemon.html181820644editdlrm
git-credential-cache--daemon.txt8910644editdlrm
git-credential-cache.html201800644editdlrm
git-credential-cache.txt24840644editdlrm
git-credential-store.html220430644editdlrm
git-credential-store.txt36370644editdlrm
git-credential.html266760644editdlrm
git-credential.txt73270644editdlrm
git-describe.html282680644editdlrm
git-describe.txt83190644editdlrm
git-diagnose.html201570644editdlrm
git-diagnose.txt22080644editdlrm
git-diff-files.html791300644editdlrm
git-diff-files.txt12250644editdlrm
git-diff-index.html843510644editdlrm
git-diff-index.txt48110644editdlrm
git-diff-tree.html1160520644editdlrm
git-diff-tree.txt41840644editdlrm
git-diff.html1070930644editdlrm
git-diff.txt80390644editdlrm
git-difftool.html270480644editdlrm
git-difftool.txt46240644editdlrm
git-fast-export.html316500644editdlrm
git-fast-export.txt112820644editdlrm
git-fast-import.html1032830644editdlrm
git-fast-import.txt599630644editdlrm
git-fetch-pack.html232550644editdlrm
git-fetch-pack.txt42480644editdlrm
git-fetch.html754560644editdlrm
git-fetch.txt118120644editdlrm
git-filter-branch.html546480644editdlrm
git-filter-branch.txt310310644editdlrm
git-fmt-merge-msg.html214350644editdlrm
git-fmt-merge-msg.txt19310644editdlrm
git-for-each-ref.html434380644editdlrm
git-for-each-ref.txt170730644editdlrm
git-for-each-repo.html192960644editdlrm
git-for-each-repo.txt15430644editdlrm
git-format-patch.html818420644editdlrm
git-format-patch.txt288760644editdlrm
git-fsck-objects.html173920644editdlrm
git-fsck-objects.txt3540644editdlrm
git-fsck.html391620644editdlrm
git-fsck.txt58820644editdlrm
git-fsmonitor--daemon.html228750644editdlrm
git-fsmonitor--daemon.txt36100644editdlrm
git-gc.html366970644editdlrm
git-gc.txt62920644editdlrm
git-get-tar-commit-id.html178350644editdlrm
git-get-tar-commit-id.txt7530644editdlrm
git-grep.html360300644editdlrm
git-grep.txt107630644editdlrm
git-hash-object.html199390644editdlrm
git-hash-object.txt21420644editdlrm
git-help.html281410644editdlrm
git-help.txt75270644editdlrm
git-hook.html188070644editdlrm
git-hook.txt10280644editdlrm
git-http-backend.html309740644editdlrm
git-http-backend.txt114720644editdlrm
git-http-fetch.html196790644editdlrm
git-http-fetch.txt17750644editdlrm
git-http-push.html213910644editdlrm
git-http-push.txt29950644editdlrm
git-imap-send.html254720644editdlrm
git-imap-send.txt35670644editdlrm
git-index-pack.html247350644editdlrm
git-index-pack.txt52050644editdlrm
git-init-db.html174600644editdlrm
git-init-db.txt4090644editdlrm
git-init.html266040644editdlrm
git-init.txt58690644editdlrm
git-interpret-trailers.html420060644editdlrm
git-interpret-trailers.txt185790644editdlrm
git-log.html1824850644editdlrm
git-log.txt68640644editdlrm
git-ls-files.html350530644editdlrm
git-ls-files.txt116220644editdlrm
git-ls-remote.html243490644editdlrm
git-ls-remote.txt48410644editdlrm
git-ls-tree.html256280644editdlrm
git-ls-tree.txt55150644editdlrm
git-mailinfo.html234020644editdlrm
git-mailinfo.txt38660644editdlrm
git-mailsplit.html192640644editdlrm
git-mailsplit.txt13420644editdlrm
git-maintenance.html460000644editdlrm
git-maintenance.txt189010644editdlrm
git-merge-base.html283800644editdlrm
git-merge-base.txt77590644editdlrm
git-merge-file.html226560644editdlrm
git-merge-file.txt37180644editdlrm
git-merge-index.html204500644editdlrm
git-merge-index.txt24450644editdlrm
git-merge-one-file.html174160644editdlrm
git-merge-one-file.txt3870644editdlrm
git-merge-tree.html334960644editdlrm
git-merge-tree.txt119230644editdlrm
git-merge.html710050644editdlrm
git-merge.txt150680644editdlrm
git-mergetool--lib.html191270644editdlrm
git-mergetool--lib.txt14670644editdlrm
git-mergetool.html397950644editdlrm
git-mergetool.txt44730644editdlrm
git-mktag.html198190644editdlrm
git-mktag.txt17820644editdlrm
git-mktree.html184740644editdlrm
git-mktree.txt10750644editdlrm
git-multi-pack-index.html235950644editdlrm
git-multi-pack-index.txt46320644editdlrm
git-mv.html200920644editdlrm
git-mv.txt21030644editdlrm
git-name-rev.html216700644editdlrm
git-name-rev.txt33520644editdlrm
git-notes.html410460644editdlrm
git-notes.txt138660644editdlrm
git-pack-objects.html423910644editdlrm
git-pack-objects.txt192970644editdlrm
git-pack-redundant.html197990644editdlrm
git-pack-redundant.txt18760644editdlrm
git-pack-refs.html211200644editdlrm
git-pack-refs.txt31360644editdlrm
git-patch-id.html203540644editdlrm
git-patch-id.txt24300644editdlrm
git-prune-packed.html185390644editdlrm
git-prune-packed.txt9460644editdlrm
git-prune.html203270644editdlrm
git-prune.txt19190644editdlrm
git-pull.html770700644editdlrm
git-pull.txt83540644editdlrm
git-push.html749930644editdlrm
git-push.txt280610644editdlrm
git-quiltimport.html194660644editdlrm
git-quiltimport.txt16930644editdlrm
git-range-diff.html316730644editdlrm
git-range-diff.txt103370644editdlrm
git-read-tree.html390780644editdlrm
git-read-tree.txt168970644editdlrm
git-rebase.html989450644editdlrm
git-rebase.txt472280644editdlrm
git-receive-pack.html304480644editdlrm
git-receive-pack.txt95260644editdlrm
git-reflog.html235140644editdlrm
git-reflog.txt45750644editdlrm
git-remote-ext.html230120644editdlrm
git-remote-ext.txt39770644editdlrm
git-remote-fd.html195010644editdlrm
git-remote-fd.txt16280644editdlrm
git-remote-helpers.html169740644editdlrm
git-remote.html299030644editdlrm
git-remote.txt87680644editdlrm
git-repack.html328190644editdlrm
git-repack.txt110200644editdlrm
git-replace.html248580644editdlrm
git-replace.txt52110644editdlrm
git-request-pull.html202950644editdlrm
git-request-pull.txt20350644editdlrm
git-rerere.html270400644editdlrm
git-rerere.txt77810644editdlrm
git-reset.html445200644editdlrm
git-reset.txt191250644editdlrm
git-restore.html281660644editdlrm
git-restore.txt70820644editdlrm
git-rev-list.html1181280644editdlrm
git-rev-list.txt32200644editdlrm
git-rev-parse.html646410644editdlrm
git-rev-parse.txt158400644editdlrm
git-revert.html267920644editdlrm
git-revert.txt54210644editdlrm
git-rm.html275840644editdlrm
git-rm.txt72360644editdlrm
git-send-pack.html245760644editdlrm
git-send-pack.txt51600644editdlrm
git-sh-i18n--envsubst.html181660644editdlrm
git-sh-i18n--envsubst.txt9280644editdlrm
git-sh-i18n.html185950644editdlrm
git-sh-i18n.txt11470644editdlrm
git-sh-setup.html212770644editdlrm
git-sh-setup.txt29760644editdlrm
git-shell.html214140644editdlrm
git-shell.txt29810644editdlrm
git-shortlog.html646180644editdlrm
git-shortlog.txt44090644editdlrm
git-show-branch.html268130644editdlrm
git-show-branch.txt65890644editdlrm
git-show-index.html195210644editdlrm
git-show-index.txt14730644editdlrm
git-show-ref.html260750644editdlrm
git-show-ref.txt66480644editdlrm
git-show.html1116440644editdlrm
git-show.txt19290644editdlrm
git-sparse-checkout.html439490644editdlrm
git-sparse-checkout.txt212580644editdlrm
git-stage.html173410644editdlrm
git-stage.txt2990644editdlrm
git-stash.html385940644editdlrm
git-stash.txt149990644editdlrm
git-status.html457180644editdlrm
git-status.txt202950644editdlrm
git-stripspace.html200160644editdlrm
git-stripspace.txt19460644editdlrm
git-submodule.html455810644editdlrm
git-submodule.txt208190644editdlrm
git-subtree.html368230644editdlrm
git-subtree.txt136870644editdlrm
git-switch.html333140644editdlrm
git-switch.txt86070644editdlrm
git-symbolic-ref.html204520644editdlrm
git-symbolic-ref.txt23270644editdlrm
git-tag.html389580644editdlrm
git-tag.txt134690644editdlrm
git-tools.html172070644editdlrm
git-tools.txt4220644editdlrm
git-unpack-file.html176450644editdlrm
git-unpack-file.txt4340644editdlrm
git-unpack-objects.html188110644editdlrm
git-unpack-objects.txt12200644editdlrm
git-update-index.html497230644editdlrm
git-update-index.txt239280644editdlrm
git-update-ref.html259090644editdlrm
git-update-ref.txt62980644editdlrm
git-update-server-info.html182550644editdlrm
git-update-server-info.txt8010644editdlrm
git-upload-archive.html197760644editdlrm
git-upload-archive.txt20870644editdlrm
git-upload-pack.html216710644editdlrm
git-upload-pack.txt29980644editdlrm
git-var.html215370644editdlrm
git-var.txt31760644editdlrm
git-verify-commit.html179480644editdlrm
git-verify-commit.txt5750644editdlrm
git-verify-pack.html189530644editdlrm
git-verify-pack.txt11110644editdlrm
git-verify-tag.html179410644editdlrm
git-verify-tag.txt5620644editdlrm
git-version.html177980644editdlrm
git-version.txt5320644editdlrm
git-web--browse.html224050644editdlrm
git-web--browse.txt35760644editdlrm
git-whatchanged.html185720644editdlrm
git-whatchanged.txt10980644editdlrm
git-worktree.html463410644editdlrm
git-worktree.txt209850644editdlrm
git-write-tree.html184410644editdlrm
git-write-tree.txt10260644editdlrm
git.html1072370644editdlrm
git.txt432540644editdlrm
gitattributes.html828450644editdlrm
gitattributes.txt495110644editdlrm
gitcli.html295840644editdlrm
gitcli.txt96970644editdlrm
gitcore-tutorial.html1001390644editdlrm
gitcore-tutorial.txt622400644editdlrm
gitcredentials.html319800644editdlrm
gitcredentials.txt113170644editdlrm
gitdiffcore.html337450644editdlrm
gitdiffcore.txt140820644editdlrm
giteveryday.html380920644editdlrm
giteveryday.txt144220644editdlrm
gitfaq.html440810644editdlrm
gitfaq.txt210690644editdlrm
gitformat-bundle.html214460644editdlrm
gitformat-bundle.txt32560644editdlrm
gitformat-chunk.html243290644editdlrm
gitformat-chunk.txt55600644editdlrm
gitformat-commit-graph.html286300644editdlrm
gitformat-commit-graph.txt78570644editdlrm
gitformat-index.html402690644editdlrm
gitformat-index.txt151800644editdlrm
gitformat-pack.html498110644editdlrm
gitformat-pack.txt235090644editdlrm
gitformat-signature.html273620644editdlrm
gitformat-signature.txt80930644editdlrm
gitglossary.html642010644editdlrm
gitglossary.txt3580644editdlrm
githooks.html565000644editdlrm
githooks.txt293310644editdlrm
gitignore.html283990644editdlrm
gitignore.txt89180644editdlrm
gitmailmap.html228190644editdlrm
gitmailmap.txt35510644editdlrm
gitmodules.html240570644editdlrm
gitmodules.txt48000644editdlrm
gitnamespaces.html221480644editdlrm
gitnamespaces.txt25090644editdlrm
gitprotocol-capabilities.html374250644editdlrm
gitprotocol-capabilities.txt153110644editdlrm
gitprotocol-common.html215650644editdlrm
gitprotocol-common.txt31770644editdlrm
gitprotocol-http.html432340644editdlrm
gitprotocol-http.txt179940644editdlrm
gitprotocol-pack.html530230644editdlrm
gitprotocol-pack.txt276780644editdlrm
gitprotocol-v2.html596900644editdlrm
gitprotocol-v2.txt314340644editdlrm
gitremote-helpers.html482150644editdlrm
gitremote-helpers.txt217850644editdlrm
gitrepository-layout.html393520644editdlrm
gitrepository-layout.txt116220644editdlrm
gitrevisions.html416210644editdlrm
gitrevisions.txt8230644editdlrm
gitsubmodules.html316990644editdlrm
gitsubmodules.txt103660644editdlrm
gittutorial-2.html345470644editdlrm
gittutorial-2.txt147500644editdlrm
gittutorial.html462630644editdlrm
gittutorial.txt229720644editdlrm
gitworkflows.html398690644editdlrm
gitworkflows.txt174140644editdlrm
glossary-content.txt326090644editdlrm
howto-index.html229910644editdlrm
howto-index.txt40010644editdlrm
i18n.txt29400644editdlrm
line-range-format.txt11620644editdlrm
line-range-options.txt7610644editdlrm
merge-options.txt72360644editdlrm
merge-strategies.txt66100644editdlrm
mergetools-diff.txt15070644editdlrm
mergetools-merge.txt25860644editdlrm
MyFirstContribution.html905720644editdlrm
MyFirstContribution.txt545960644editdlrm
MyFirstObjectWalk.html605540644editdlrm
MyFirstObjectWalk.txt289790644editdlrm
object-format-disclaimer.txt4700644editdlrm
pretty-formats.txt156690644editdlrm
pretty-options.txt42010644editdlrm
pull-fetch-param.txt54760644editdlrm
README.md36520644editdlrm
ref-reachability-filters.txt3910644editdlrm
rerere-options.txt4140644editdlrm
rev-list-description.txt25310644editdlrm
rev-list-options.txt469060644editdlrm
ReviewingGuidelines.html268310644editdlrm
ReviewingGuidelines.txt81000644editdlrm
revisions.txt171090644editdlrm
scalar.html260550644editdlrm
scalar.txt60560644editdlrm
sequencer.txt4720644editdlrm
signoff-option.txt7810644editdlrm
SubmittingPatches.html556600644editdlrm
SubmittingPatches.txt301470644editdlrm
ToolsForGit.html190200644editdlrm
ToolsForGit.txt13480644editdlrm
trace2-target-values.txt5290644editdlrm
transfer-data-leaks.txt17120644editdlrm
urls-remotes.txt26420644editdlrm
urls.txt36340644editdlrm
user-manual.html2757310644editdlrm
user-manual.txt1735180644editdlrm
Edit: /usr/share/doc/git/gitcli.html (29584B)
gitcli(7)

SYNOPSIS

gitcli

DESCRIPTION

This manual describes the convention used throughout Git CLI.

Many commands take revisions (most often "commits", but sometimes "tree-ish", depending on the context and command) and paths as their arguments. Here are the rules:

  • Options come first and then args. A subcommand may take dashed options (which may take their own arguments, e.g. "--max-parents 2") and arguments. You SHOULD give dashed options first and then arguments. Some commands may accept dashed options after you have already given non-option arguments (which may make the command ambiguous), but you should not rely on it (because eventually we may find a way to fix these ambiguities by enforcing the "options then args" rule).

  • Revisions come first and then paths. E.g. in git diff v1.0 v2.0 arch/x86 include/asm-x86, v1.0 and v2.0 are revisions and arch/x86 and include/asm-x86 are paths.

  • When an argument can be misunderstood as either a revision or a path, they can be disambiguated by placing -- between them. E.g. git diff -- HEAD is, "I have a file called HEAD in my work tree. Please show changes between the version I staged in the index and what I have in the work tree for that file", not "show the difference between the HEAD commit and the work tree as a whole". You can say git diff HEAD -- to ask for the latter.

  • Without disambiguating --, Git makes a reasonable guess, but errors out and asks you to disambiguate when ambiguous. E.g. if you have a file called HEAD in your work tree, git diff HEAD is ambiguous, and you have to say either git diff HEAD -- or git diff -- HEAD to disambiguate.

  • Because -- disambiguates revisions and paths in some commands, it cannot be used for those commands to separate options and revisions. You can use --end-of-options for this (it also works for commands that do not distinguish between revisions in paths, in which case it is simply an alias for --).

    When writing a script that is expected to handle random user-input, it is a good practice to make it explicit which arguments are which by placing disambiguating -- at appropriate places.

  • Many commands allow wildcards in paths, but you need to protect them from getting globbed by the shell. These two mean different things:

    $ git restore *.c
    $ git restore \*.c

    The former lets your shell expand the fileglob, and you are asking the dot-C files in your working tree to be overwritten with the version in the index. The latter passes the *.c to Git, and you are asking the paths in the index that match the pattern to be checked out to your working tree. After running git add hello.c; rm hello.c, you will not see hello.c in your working tree with the former, but with the latter you will.

  • Just as the filesystem . (period) refers to the current directory, using a . as a repository name in Git (a dot-repository) is a relative path and means your current repository.

Here are the rules regarding the "flags" that you should follow when you are scripting Git:

  • It’s preferred to use the non-dashed form of Git commands, which means that you should prefer git foo to git-foo.

  • Splitting short options to separate words (prefer git foo -a -b to git foo -ab, the latter may not even work).

  • When a command-line option takes an argument, use the stuck form. In other words, write git foo -oArg instead of git foo -o Arg for short options, and git foo --long-opt=Arg instead of git foo --long-opt Arg for long options. An option that takes optional option-argument must be written in the stuck form.

  • When you give a revision parameter to a command, make sure the parameter is not ambiguous with a name of a file in the work tree. E.g. do not write git log -1 HEAD but write git log -1 HEAD --; the former will not work if you happen to have a file called HEAD in the work tree.

  • Many commands allow a long option --option to be abbreviated only to their unique prefix (e.g. if there is no other option whose name begins with opt, you may be able to spell --opt to invoke the --option flag), but you should fully spell them out when writing your scripts; later versions of Git may introduce a new option whose name shares the same prefix, e.g. --optimize, to make a short prefix that used to be unique no longer unique.

ENHANCED OPTION PARSER

From the Git 1.5.4 series and further, many Git commands (not all of them at the time of the writing though) come with an enhanced option parser.

Here is a list of the facilities provided by this option parser.

Magic Options

Commands which have the enhanced option parser activated all understand a couple of magic command-line options:

-h

gives a pretty printed usage of the command.

$ git describe -h
usage: git describe [<options>] <commit-ish>*
   or: git describe [<options>] --dirty

    --contains            find the tag that comes after the commit
    --debug               debug search strategy on stderr
    --all                 use any ref
    --tags                use any tag, even unannotated
    --long                always use long format
    --abbrev[=<n>]        use <n> digits to display SHA-1s

Note that some subcommand (e.g. git grep) may behave differently when there are things on the command line other than -h, but git subcmd -h without anything else on the command line is meant to consistently give the usage.

--help-all

Some Git commands take options that are only used for plumbing or that are deprecated, and such options are hidden from the default usage. This option gives the full list of options.

Negating options

Options with long option names can be negated by prefixing --no-. For example, git branch has the option --track which is on by default. You can use --no-track to override that behaviour. The same goes for --color and --no-color.

Aggregating short options

Commands that support the enhanced option parser allow you to aggregate short options. This means that you can for example use git rm -rf or git clean -fdx.

Abbreviating long options

Commands that support the enhanced option parser accepts unique prefix of a long option as if it is fully spelled out, but use this with a caution. For example, git commit --amen behaves as if you typed git commit --amend, but that is true only until a later version of Git introduces another option that shares the same prefix, e.g. git commit --amenity option.

Separating argument from the option

You can write the mandatory option parameter to an option as a separate word on the command line. That means that all the following uses work:

$ git foo --long-opt=Arg
$ git foo --long-opt Arg
$ git foo -oArg
$ git foo -o Arg

However, this is NOT allowed for switches with an optional value, where the stuck form must be used:

$ git describe --abbrev HEAD     # correct
$ git describe --abbrev=10 HEAD  # correct
$ git describe --abbrev 10 HEAD  # NOT WHAT YOU MEANT

NOTES ON FREQUENTLY CONFUSED OPTIONS

Many commands that can work on files in the working tree and/or in the index can take --cached and/or --index options. Sometimes people incorrectly think that, because the index was originally called cache, these two are synonyms. They are not — these two options mean very different things.

  • The --cached option is used to ask a command that usually works on files in the working tree to only work with the index. For example, git grep, when used without a commit to specify from which commit to look for strings in, usually works on files in the working tree, but with the --cached option, it looks for strings in the index.

  • The --index option is used to ask a command that usually works on files in the working tree to also affect the index. For example, git stash apply usually merges changes recorded in a stash entry to the working tree, but with the --index option, it also merges changes to the index as well.

git apply command can be used with --cached and --index (but not at the same time). Usually the command only affects the files in the working tree, but with --index, it patches both the files and their index entries, and with --cached, it modifies only the index entries.

Some other commands that also work on files in the working tree and/or in the index can take --staged and/or --worktree.

  • --staged is exactly like --cached, which is used to ask a command to only work on the index, not the working tree.

  • --worktree is the opposite, to ask a command to work on the working tree only, not the index.

  • The two options can be specified together to ask a command to work on both the index and the working tree.

GIT

Part of the git(1) suite