6 git - the stupid content tracker
12 'git' [-v | --version] [-h | --help] [-C <path>] [-c <name>=<value>]
13 [--exec-path[=<path>]] [--html-path] [--man-path] [--info-path]
14 [-p|--paginate|-P|--no-pager] [--no-replace-objects] [--bare]
15 [--git-dir=<path>] [--work-tree=<path>] [--namespace=<name>]
16 [--config-env=<name>=<envvar>] <command> [<args>]
20 Git is a fast, scalable, distributed revision control system with an
21 unusually rich command set that provides both high-level operations
22 and full access to internals.
24 See linkgit:gittutorial[7] to get started, then see
25 linkgit:giteveryday[7] for a useful minimum set of
26 commands. The link:user-manual.html[Git User's Manual] has a more
27 in-depth introduction.
29 After you mastered the basic concepts, you can come back to this
30 page to learn what commands Git offers. You can learn more about
31 individual Git commands with "git help command". linkgit:gitcli[7]
32 manual page gives you an overview of the command-line command syntax.
34 A formatted and hyperlinked copy of the latest Git documentation
35 can be viewed at https://git.github.io/htmldocs/git.html
36 or https://git-scm.com/docs.
43 Prints the Git suite version that the 'git' program came from.
45 This option is internally converted to `git version ...` and accepts
46 the same options as the linkgit:git-version[1] command. If `--help` is
47 also given, it takes precedence over `--version`.
51 Prints the synopsis and a list of the most commonly used
52 commands. If the option `--all` or `-a` is given then all
53 available commands are printed. If a Git command is named this
54 option will bring up the manual page for that command.
56 Other options are available to control how the manual page is
57 displayed. See linkgit:git-help[1] for more information,
58 because `git --help ...` is converted internally into `git
62 Run as if git was started in '<path>' instead of the current working
63 directory. When multiple `-C` options are given, each subsequent
64 non-absolute `-C <path>` is interpreted relative to the preceding `-C
65 <path>`. If '<path>' is present but empty, e.g. `-C ""`, then the
66 current working directory is left unchanged.
68 This option affects options that expect path name like `--git-dir` and
69 `--work-tree` in that their interpretations of the path names would be
70 made relative to the working directory caused by the `-C` option. For
71 example the following invocations are equivalent:
73 git --git-dir=a.git --work-tree=b -C c status
74 git --git-dir=c/a.git --work-tree=c/b status
77 Pass a configuration parameter to the command. The value
78 given will override values from configuration files.
79 The <name> is expected in the same format as listed by
80 'git config' (subkeys separated by dots).
82 Note that omitting the `=` in `git -c foo.bar ...` is allowed and sets
83 `foo.bar` to the boolean true value (just like `[foo]bar` would in a
84 config file). Including the equals but with an empty value (like `git -c
85 foo.bar= ...`) sets `foo.bar` to the empty string which `git config
86 --type=bool` will convert to `false`.
88 --config-env=<name>=<envvar>::
89 Like `-c <name>=<value>`, give configuration variable
90 '<name>' a value, where <envvar> is the name of an
91 environment variable from which to retrieve the value. Unlike
92 `-c` there is no shortcut for directly setting the value to an
93 empty string, instead the environment variable itself must be
94 set to the empty string. It is an error if the `<envvar>` does not exist
95 in the environment. `<envvar>` may not contain an equals sign
96 to avoid ambiguity with `<name>` containing one.
98 This is useful for cases where you want to pass transitory
99 configuration options to git, but are doing so on operating systems
100 where other processes might be able to read your command line
101 (e.g. `/proc/self/cmdline`), but not your environment
102 (e.g. `/proc/self/environ`). That behavior is the default on
103 Linux, but may not be on your system.
105 Note that this might add security for variables such as
106 `http.extraHeader` where the sensitive information is part of
107 the value, but not e.g. `url.<base>.insteadOf` where the
108 sensitive information can be part of the key.
110 --exec-path[=<path>]::
111 Path to wherever your core Git programs are installed.
112 This can also be controlled by setting the GIT_EXEC_PATH
113 environment variable. If no path is given, 'git' will print
114 the current setting and then exit.
117 Print the path, without trailing slash, where Git's HTML
118 documentation is installed and exit.
121 Print the manpath (see `man(1)`) for the man pages for
122 this version of Git and exit.
125 Print the path where the Info files documenting this
126 version of Git are installed and exit.
130 Pipe all output into 'less' (or if set, $PAGER) if standard
131 output is a terminal. This overrides the `pager.<cmd>`
132 configuration options (see the "Configuration Mechanism" section
137 Do not pipe Git output into a pager.
140 Set the path to the repository (".git" directory). This can also be
141 controlled by setting the `GIT_DIR` environment variable. It can be
142 an absolute path or relative path to current working directory.
144 Specifying the location of the ".git" directory using this
145 option (or `GIT_DIR` environment variable) turns off the
146 repository discovery that tries to find a directory with
147 ".git" subdirectory (which is how the repository and the
148 top-level of the working tree are discovered), and tells Git
149 that you are at the top level of the working tree. If you
150 are not at the top-level directory of the working tree, you
151 should tell Git where the top-level of the working tree is,
152 with the `--work-tree=<path>` option (or `GIT_WORK_TREE`
153 environment variable)
155 If you just want to run git as if it was started in `<path>` then use
159 Set the path to the working tree. It can be an absolute path
160 or a path relative to the current working directory.
161 This can also be controlled by setting the GIT_WORK_TREE
162 environment variable and the core.worktree configuration
163 variable (see core.worktree in linkgit:git-config[1] for a
164 more detailed discussion).
167 Set the Git namespace. See linkgit:gitnamespaces[7] for more
168 details. Equivalent to setting the `GIT_NAMESPACE` environment
172 Treat the repository as a bare repository. If GIT_DIR
173 environment is not set, it is set to the current working
176 --no-replace-objects::
177 Do not use replacement refs to replace Git objects.
178 This is equivalent to exporting the `GIT_NO_REPLACE_OBJECTS`
179 environment variable with any value.
180 See linkgit:git-replace[1] for more information.
183 Do not fetch missing objects from the promisor remote on
184 demand. Useful together with `git cat-file -e <object>` to
185 see if the object is locally available.
186 This is equivalent to setting the `GIT_NO_LAZY_FETCH`
187 environment variable to `1`.
189 --literal-pathspecs::
190 Treat pathspecs literally (i.e. no globbing, no pathspec magic).
191 This is equivalent to setting the `GIT_LITERAL_PATHSPECS` environment
195 Add "glob" magic to all pathspec. This is equivalent to setting
196 the `GIT_GLOB_PATHSPECS` environment variable to `1`. Disabling
197 globbing on individual pathspecs can be done using pathspec
201 Add "literal" magic to all pathspec. This is equivalent to setting
202 the `GIT_NOGLOB_PATHSPECS` environment variable to `1`. Enabling
203 globbing on individual pathspecs can be done using pathspec
207 Add "icase" magic to all pathspec. This is equivalent to setting
208 the `GIT_ICASE_PATHSPECS` environment variable to `1`.
210 --no-optional-locks::
211 Do not perform optional operations that require locks. This is
212 equivalent to setting the `GIT_OPTIONAL_LOCKS` to `0`.
214 --list-cmds=<group>[,<group>...]::
215 List commands by group. This is an internal/experimental
216 option and may change or be removed in the future. Supported
217 groups are: builtins, parseopt (builtin commands that use
218 parse-options), main (all commands in libexec directory),
219 others (all other commands in `$PATH` that have git- prefix),
220 list-<category> (see categories in command-list.txt),
221 nohelpers (exclude helper commands), alias and config
222 (retrieve command list from config variable completion.commands)
224 --attr-source=<tree-ish>::
225 Read gitattributes from <tree-ish> instead of the worktree. See
226 linkgit:gitattributes[5]. This is equivalent to setting the
227 `GIT_ATTR_SOURCE` environment variable.
232 We divide Git into high level ("porcelain") commands and low level
233 ("plumbing") commands.
235 High-level commands (porcelain)
236 -------------------------------
238 We separate the porcelain commands into the main commands and some
239 ancillary user utilities.
241 Main porcelain commands
242 ~~~~~~~~~~~~~~~~~~~~~~~
244 include::cmds-mainporcelain.txt[]
250 include::cmds-ancillarymanipulators.txt[]
254 include::cmds-ancillaryinterrogators.txt[]
257 Interacting with Others
258 ~~~~~~~~~~~~~~~~~~~~~~~
260 These commands are to interact with foreign SCM and with other
261 people via patch over e-mail.
263 include::cmds-foreignscminterface.txt[]
265 Reset, restore and revert
266 ~~~~~~~~~~~~~~~~~~~~~~~~~
267 There are three commands with similar names: `git reset`,
268 `git restore` and `git revert`.
270 * linkgit:git-revert[1] is about making a new commit that reverts the
271 changes made by other commits.
273 * linkgit:git-restore[1] is about restoring files in the working tree
274 from either the index or another commit. This command does not
275 update your branch. The command can also be used to restore files in
276 the index from another commit.
278 * linkgit:git-reset[1] is about updating your branch, moving the tip
279 in order to add or remove commits from the branch. This operation
280 changes the commit history.
282 `git reset` can also be used to restore the index, overlapping with
286 Low-level commands (plumbing)
287 -----------------------------
289 Although Git includes its
290 own porcelain layer, its low-level commands are sufficient to support
291 development of alternative porcelains. Developers of such porcelains
292 might start by reading about linkgit:git-update-index[1] and
293 linkgit:git-read-tree[1].
295 The interface (input, output, set of options and the semantics)
296 to these low-level commands are meant to be a lot more stable
297 than Porcelain level commands, because these commands are
298 primarily for scripted use. The interface to Porcelain commands
299 on the other hand are subject to change in order to improve the
302 The following description divides
303 the low-level commands into commands that manipulate objects (in
304 the repository, index, and working tree), commands that interrogate and
305 compare objects, and commands that move objects and references between
309 Manipulation commands
310 ~~~~~~~~~~~~~~~~~~~~~
312 include::cmds-plumbingmanipulators.txt[]
315 Interrogation commands
316 ~~~~~~~~~~~~~~~~~~~~~~
318 include::cmds-plumbinginterrogators.txt[]
320 In general, the interrogate commands do not touch the files in
327 include::cmds-synchingrepositories.txt[]
329 The following are helper commands used by the above; end users
330 typically do not use them directly.
332 include::cmds-synchelpers.txt[]
335 Internal helper commands
336 ~~~~~~~~~~~~~~~~~~~~~~~~
338 These are internal helper commands used by other commands; end
339 users typically do not use them directly.
341 include::cmds-purehelpers.txt[]
346 The following documentation pages are guides about Git concepts.
348 include::cmds-guide.txt[]
350 Repository, command and file interfaces
351 ---------------------------------------
353 This documentation discusses repository and command interfaces which
354 users are expected to interact with directly. See `--user-formats` in
355 linkgit:git-help[1] for more details on the criteria.
357 include::cmds-userinterfaces.txt[]
359 File formats, protocols and other developer interfaces
360 ------------------------------------------------------
362 This documentation discusses file formats, over-the-wire protocols and
363 other git developer interfaces. See `--developer-interfaces` in
366 include::cmds-developerinterfaces.txt[]
368 Configuration Mechanism
369 -----------------------
371 Git uses a simple text format to store customizations that are per
372 repository and are per user. Such a configuration file may look
377 # A '#' or ';' character indicates a comment.
382 ; Don't trust file modes
387 name = "Junio C Hamano"
388 email = "gitster@pobox.com"
392 Various commands read from the configuration file and adjust
393 their operation accordingly. See linkgit:git-config[1] for a
394 list and more details about the configuration mechanism.
397 Identifier Terminology
398 ----------------------
400 Indicates the object name for any type of object.
403 Indicates a blob object name.
406 Indicates a tree object name.
409 Indicates a commit object name.
412 Indicates a tree, commit or tag object name. A
413 command that takes a <tree-ish> argument ultimately wants to
414 operate on a <tree> object but automatically dereferences
415 <commit> and <tag> objects that point at a <tree>.
418 Indicates a commit or tag object name. A
419 command that takes a <commit-ish> argument ultimately wants to
420 operate on a <commit> object but automatically dereferences
421 <tag> objects that point at a <commit>.
424 Indicates that an object type is required.
425 Currently one of: `blob`, `tree`, `commit`, or `tag`.
428 Indicates a filename - almost always relative to the
429 root of the tree structure `GIT_INDEX_FILE` describes.
433 Any Git command accepting any <object> can also use the following
437 indicates the head of the current branch.
441 (i.e. a `refs/tags/<tag>` reference).
445 (i.e. a `refs/heads/<head>` reference).
447 For a more complete list of ways to spell object names, see
448 "SPECIFYING REVISIONS" section in linkgit:gitrevisions[7].
451 File/Directory Structure
452 ------------------------
454 Please see the linkgit:gitrepository-layout[5] document.
456 Read linkgit:githooks[5] for more details about each hook.
458 Higher level SCMs may provide and manage additional information in the
464 Please see linkgit:gitglossary[7].
467 Environment Variables
468 ---------------------
469 Various Git commands pay attention to environment variables and change
470 their behavior. The environment variables marked as "Boolean" take
471 their values the same way as Boolean valued configuration variables, e.g.
472 "true", "yes", "on" and positive numbers are taken as "yes".
474 Here are the variables:
478 These environment variables apply to 'all' core Git commands. Nb: it
479 is worth noting that they may be used/overridden by SCMS sitting above
480 Git so take care if using a foreign front-end.
483 This environment variable specifies an alternate
484 index file. If not specified, the default of `$GIT_DIR/index`
487 `GIT_INDEX_VERSION`::
488 This environment variable specifies what index version is used
489 when writing the index file out. It won't affect existing index
490 files. By default index file version 2 or 3 is used. See
491 linkgit:git-update-index[1] for more information.
493 `GIT_OBJECT_DIRECTORY`::
494 If the object storage directory is specified via this
495 environment variable then the sha1 directories are created
496 underneath - otherwise the default `$GIT_DIR/objects`
499 `GIT_ALTERNATE_OBJECT_DIRECTORIES`::
500 Due to the immutable nature of Git objects, old objects can be
501 archived into shared, read-only directories. This variable
502 specifies a ":" separated (on Windows ";" separated) list
503 of Git object directories which can be used to search for Git
504 objects. New objects will not be written to these directories.
506 Entries that begin with `"` (double-quote) will be interpreted
507 as C-style quoted paths, removing leading and trailing
508 double-quotes and respecting backslash escapes. E.g., the value
509 `"path-with-\"-and-:-in-it":vanilla-path` has two paths:
510 `path-with-"-and-:-in-it` and `vanilla-path`.
513 If the `GIT_DIR` environment variable is set then it
514 specifies a path to use instead of the default `.git`
515 for the base of the repository.
516 The `--git-dir` command-line option also sets this value.
519 Set the path to the root of the working tree.
520 This can also be controlled by the `--work-tree` command-line
521 option and the core.worktree configuration variable.
524 Set the Git namespace; see linkgit:gitnamespaces[7] for details.
525 The `--namespace` command-line option also sets this value.
527 `GIT_CEILING_DIRECTORIES`::
528 This should be a colon-separated list of absolute paths. If
529 set, it is a list of directories that Git should not chdir up
530 into while looking for a repository directory (useful for
531 excluding slow-loading network directories). It will not
532 exclude the current working directory or a GIT_DIR set on the
533 command line or in the environment. Normally, Git has to read
534 the entries in this list and resolve any symlink that
535 might be present in order to compare them with the current
536 directory. However, if even this access is slow, you
537 can add an empty entry to the list to tell Git that the
538 subsequent entries are not symlinks and needn't be resolved;
540 `GIT_CEILING_DIRECTORIES=/maybe/symlink::/very/slow/non/symlink`.
542 `GIT_DISCOVERY_ACROSS_FILESYSTEM`::
543 When run in a directory that does not have ".git" repository
544 directory, Git tries to find such a directory in the parent
545 directories to find the top of the working tree, but by default it
546 does not cross filesystem boundaries. This Boolean environment variable
547 can be set to true to tell Git not to stop at filesystem
548 boundaries. Like `GIT_CEILING_DIRECTORIES`, this will not affect
549 an explicit repository directory set via `GIT_DIR` or on the
553 If this variable is set to a path, non-worktree files that are
554 normally in $GIT_DIR will be taken from this path
555 instead. Worktree-specific files such as HEAD or index are
556 taken from $GIT_DIR. See linkgit:gitrepository-layout[5] and
557 linkgit:git-worktree[1] for
558 details. This variable has lower precedence than other path
559 variables such as GIT_INDEX_FILE, GIT_OBJECT_DIRECTORY...
562 If this variable is set, the default hash algorithm for new
563 repositories will be set to this value. This value is
564 ignored when cloning and the setting of the remote repository
565 is always used. The default is "sha1".
566 See `--object-format` in linkgit:git-init[1].
568 `GIT_DEFAULT_REF_FORMAT`::
569 If this variable is set, the default reference backend format for new
570 repositories will be set to this value. The default is "files".
571 See `--ref-format` in linkgit:git-init[1].
576 The human-readable name used in the author identity when creating commit or
577 tag objects, or when writing reflogs. Overrides the `user.name` and
578 `author.name` configuration settings.
581 The email address used in the author identity when creating commit or
582 tag objects, or when writing reflogs. Overrides the `user.email` and
583 `author.email` configuration settings.
586 The date used for the author identity when creating commit or tag objects, or
587 when writing reflogs. See linkgit:git-commit[1] for valid formats.
589 `GIT_COMMITTER_NAME`::
590 The human-readable name used in the committer identity when creating commit or
591 tag objects, or when writing reflogs. Overrides the `user.name` and
592 `committer.name` configuration settings.
594 `GIT_COMMITTER_EMAIL`::
595 The email address used in the author identity when creating commit or
596 tag objects, or when writing reflogs. Overrides the `user.email` and
597 `committer.email` configuration settings.
599 `GIT_COMMITTER_DATE`::
600 The date used for the committer identity when creating commit or tag objects, or
601 when writing reflogs. See linkgit:git-commit[1] for valid formats.
604 The email address used in the author and committer identities if no other
605 relevant environment variable or configuration setting has been set.
610 Only valid setting is "--unified=??" or "-u??" to set the
611 number of context lines shown when a unified diff is created.
612 This takes precedence over any "-U" or "--unified" option
613 value passed on the Git diff command line.
615 `GIT_EXTERNAL_DIFF`::
616 When the environment variable `GIT_EXTERNAL_DIFF` is set, the
617 program named by it is called to generate diffs, and Git
618 does not use its builtin diff machinery.
619 For a path that is added, removed, or modified,
620 `GIT_EXTERNAL_DIFF` is called with 7 parameters:
622 path old-file old-hex old-mode new-file new-hex new-mode
626 <old|new>-file:: are files GIT_EXTERNAL_DIFF can use to read the
627 contents of <old|new>,
628 <old|new>-hex:: are the 40-hexdigit SHA-1 hashes,
629 <old|new>-mode:: are the octal representation of the file modes.
631 The file parameters can point at the user's working file
632 (e.g. `new-file` in "git-diff-files"), `/dev/null` (e.g. `old-file`
633 when a new file is added), or a temporary file (e.g. `old-file` in the
634 index). `GIT_EXTERNAL_DIFF` should not worry about unlinking the
635 temporary file -- it is removed when `GIT_EXTERNAL_DIFF` exits.
637 For a path that is unmerged, `GIT_EXTERNAL_DIFF` is called with 1
640 For each path `GIT_EXTERNAL_DIFF` is called, two environment variables,
641 `GIT_DIFF_PATH_COUNTER` and `GIT_DIFF_PATH_TOTAL` are set.
643 `GIT_DIFF_PATH_COUNTER`::
644 A 1-based counter incremented by one for every path.
646 `GIT_DIFF_PATH_TOTAL`::
647 The total number of paths.
651 `GIT_MERGE_VERBOSITY`::
652 A number controlling the amount of output shown by
653 the recursive merge strategy. Overrides merge.verbosity.
654 See linkgit:git-merge[1]
657 This environment variable overrides `$PAGER`. If it is set
658 to an empty string or to the value "cat", Git will not launch
659 a pager. See also the `core.pager` option in
660 linkgit:git-config[1].
662 `GIT_PROGRESS_DELAY`::
663 A number controlling how many seconds to delay before showing
664 optional progress indicators. Defaults to 2.
667 This environment variable overrides `$EDITOR` and `$VISUAL`.
668 It is used by several Git commands when, on interactive mode,
669 an editor is to be launched. See also linkgit:git-var[1]
670 and the `core.editor` option in linkgit:git-config[1].
672 `GIT_SEQUENCE_EDITOR`::
673 This environment variable overrides the configured Git editor
674 when editing the todo list of an interactive rebase. See also
675 linkgit:git-rebase[1] and the `sequence.editor` option in
676 linkgit:git-config[1].
680 If either of these environment variables is set then 'git fetch'
681 and 'git push' will use the specified command instead of 'ssh'
682 when they need to connect to a remote system.
683 The command-line parameters passed to the configured command are
684 determined by the ssh variant. See `ssh.variant` option in
685 linkgit:git-config[1] for details.
687 `$GIT_SSH_COMMAND` takes precedence over `$GIT_SSH`, and is interpreted
688 by the shell, which allows additional arguments to be included.
689 `$GIT_SSH` on the other hand must be just the path to a program
690 (which can be a wrapper shell script, if additional arguments are
693 Usually it is easier to configure any desired options through your
694 personal `.ssh/config` file. Please consult your ssh documentation
698 If this environment variable is set, it overrides Git's autodetection
699 whether `GIT_SSH`/`GIT_SSH_COMMAND`/`core.sshCommand` refer to OpenSSH,
700 plink or tortoiseplink. This variable overrides the config setting
701 `ssh.variant` that serves the same purpose.
703 `GIT_SSL_NO_VERIFY`::
704 Setting and exporting this environment variable to any value
705 tells Git not to verify the SSL certificate when fetching or
709 Sets the treeish that gitattributes will be read from.
712 If this environment variable is set, then Git commands which need to
713 acquire passwords or passphrases (e.g. for HTTP or IMAP authentication)
714 will call this program with a suitable prompt as command-line argument
715 and read the password from its STDOUT. See also the `core.askPass`
716 option in linkgit:git-config[1].
718 `GIT_TERMINAL_PROMPT`::
719 If this Boolean environment variable is set to false, git will not prompt
720 on the terminal (e.g., when asking for HTTP authentication).
722 `GIT_CONFIG_GLOBAL`::
723 `GIT_CONFIG_SYSTEM`::
724 Take the configuration from the given files instead from global or
725 system-level configuration files. If `GIT_CONFIG_SYSTEM` is set, the
726 system config file defined at build time (usually `/etc/gitconfig`)
727 will not be read. Likewise, if `GIT_CONFIG_GLOBAL` is set, neither
728 `$HOME/.gitconfig` nor `$XDG_CONFIG_HOME/git/config` will be read. Can
729 be set to `/dev/null` to skip reading configuration files of the
732 `GIT_CONFIG_NOSYSTEM`::
733 Whether to skip reading settings from the system-wide
734 `$(prefix)/etc/gitconfig` file. This Boolean environment variable can
735 be used along with `$HOME` and `$XDG_CONFIG_HOME` to create a
736 predictable environment for a picky script, or you can set it
737 to true to temporarily avoid using a buggy `/etc/gitconfig` file while
738 waiting for someone with sufficient permissions to fix it.
741 If this Boolean environment variable is set to true, then commands such
742 as 'git blame' (in incremental mode), 'git rev-list', 'git log',
743 'git check-attr' and 'git check-ignore' will
744 force a flush of the output stream after each record have been
746 variable is set to false, the output of these commands will be done
747 using completely buffered I/O. If this environment variable is
748 not set, Git will choose buffered or record-oriented flushing
749 based on whether stdout appears to be redirected to a file or not.
752 Enables general trace messages, e.g. alias expansion, built-in
753 command execution and external command execution.
755 If this variable is set to "1", "2" or "true" (comparison
756 is case insensitive), trace messages will be printed to
759 If the variable is set to an integer value greater than 2
760 and lower than 10 (strictly) then Git will interpret this
761 value as an open file descriptor and will try to write the
762 trace messages into this file descriptor.
764 Alternatively, if the variable is set to an absolute path
765 (starting with a '/' character), Git will interpret this
766 as a file path and will try to append the trace messages
769 Unsetting the variable, or setting it to empty, "0" or
770 "false" (case insensitive) disables trace messages.
772 `GIT_TRACE_FSMONITOR`::
773 Enables trace messages for the filesystem monitor extension.
774 See `GIT_TRACE` for available trace output options.
776 `GIT_TRACE_PACK_ACCESS`::
777 Enables trace messages for all accesses to any packs. For each
778 access, the pack file name and an offset in the pack is
779 recorded. This may be helpful for troubleshooting some
780 pack-related performance problems.
781 See `GIT_TRACE` for available trace output options.
784 Enables trace messages for all packets coming in or out of a
785 given program. This can help with debugging object negotiation
786 or other protocol issues. Tracing is turned off at a packet
787 starting with "PACK" (but see `GIT_TRACE_PACKFILE` below).
788 See `GIT_TRACE` for available trace output options.
790 `GIT_TRACE_PACKFILE`::
791 Enables tracing of packfiles sent or received by a
792 given program. Unlike other trace output, this trace is
793 verbatim: no headers, and no quoting of binary data. You almost
794 certainly want to direct into a file (e.g.,
795 `GIT_TRACE_PACKFILE=/tmp/my.pack`) rather than displaying it on
796 the terminal or mixing it with other trace output.
798 Note that this is currently only implemented for the client side
799 of clones and fetches.
801 `GIT_TRACE_PERFORMANCE`::
802 Enables performance related trace messages, e.g. total execution
803 time of each Git command.
804 See `GIT_TRACE` for available trace output options.
807 Enables trace messages for operations on the ref database.
808 See `GIT_TRACE` for available trace output options.
811 Enables trace messages printing the .git, working tree and current
812 working directory after Git has completed its setup phase.
813 See `GIT_TRACE` for available trace output options.
815 `GIT_TRACE_SHALLOW`::
816 Enables trace messages that can help debugging fetching /
817 cloning of shallow repositories.
818 See `GIT_TRACE` for available trace output options.
821 Enables a curl full trace dump of all incoming and outgoing data,
822 including descriptive information, of the git transport protocol.
823 This is similar to doing curl `--trace-ascii` on the command line.
824 See `GIT_TRACE` for available trace output options.
826 `GIT_TRACE_CURL_NO_DATA`::
827 When a curl trace is enabled (see `GIT_TRACE_CURL` above), do not dump
828 data (that is, only dump info lines and headers).
831 Enables more detailed trace messages from the "trace2" library.
832 Output from `GIT_TRACE2` is a simple text-based format for human
835 If this variable is set to "1", "2" or "true" (comparison
836 is case insensitive), trace messages will be printed to
839 If the variable is set to an integer value greater than 2
840 and lower than 10 (strictly) then Git will interpret this
841 value as an open file descriptor and will try to write the
842 trace messages into this file descriptor.
844 Alternatively, if the variable is set to an absolute path
845 (starting with a '/' character), Git will interpret this
846 as a file path and will try to append the trace messages
847 to it. If the path already exists and is a directory, the
848 trace messages will be written to files (one per process)
849 in that directory, named according to the last component
850 of the SID and an optional counter (to avoid filename
853 In addition, if the variable is set to
854 `af_unix:[<socket-type>:]<absolute-pathname>`, Git will try
855 to open the path as a Unix Domain Socket. The socket type
856 can be either `stream` or `dgram`.
858 Unsetting the variable, or setting it to empty, "0" or
859 "false" (case insensitive) disables trace messages.
861 See link:technical/api-trace2.html[Trace2 documentation]
866 This setting writes a JSON-based format that is suited for machine
868 See `GIT_TRACE2` for available trace output options and
869 link:technical/api-trace2.html[Trace2 documentation] for full details.
872 In addition to the text-based messages available in `GIT_TRACE2`, this
873 setting writes a column-based format for understanding nesting
875 See `GIT_TRACE2` for available trace output options and
876 link:technical/api-trace2.html[Trace2 documentation] for full details.
879 By default, when tracing is activated, Git redacts the values of
880 cookies, the "Authorization:" header, the "Proxy-Authorization:"
881 header and packfile URIs. Set this Boolean environment variable to false to prevent this
884 `GIT_NO_REPLACE_OBJECTS`::
885 Setting and exporting this environment variable tells Git to
886 ignore replacement refs and do not replace Git objects.
888 `GIT_LITERAL_PATHSPECS`::
889 Setting this Boolean environment variable to true will cause Git to treat all
890 pathspecs literally, rather than as glob patterns. For example,
891 running `GIT_LITERAL_PATHSPECS=1 git log -- '*.c'` will search
892 for commits that touch the path `*.c`, not any paths that the
893 glob `*.c` matches. You might want this if you are feeding
894 literal paths to Git (e.g., paths previously given to you by
895 `git ls-tree`, `--raw` diff output, etc).
897 `GIT_GLOB_PATHSPECS`::
898 Setting this Boolean environment variable to true will cause Git to treat all
899 pathspecs as glob patterns (aka "glob" magic).
901 `GIT_NOGLOB_PATHSPECS`::
902 Setting this Boolean environment variable to true will cause Git to treat all
903 pathspecs as literal (aka "literal" magic).
905 `GIT_ICASE_PATHSPECS`::
906 Setting this Boolean environment variable to true will cause Git to treat all
907 pathspecs as case-insensitive.
909 `GIT_NO_LAZY_FETCH`::
910 Setting this Boolean environment variable to true tells Git
911 not to lazily fetch missing objects from the promisor remote
914 `GIT_REFLOG_ACTION`::
915 When a ref is updated, reflog entries are created to keep
916 track of the reason why the ref was updated (which is
917 typically the name of the high-level command that updated
918 the ref), in addition to the old and new values of the ref.
919 A scripted Porcelain command can use set_reflog_action
920 helper function in `git-sh-setup` to set its name to this
921 variable when it is invoked as the top level command by the
922 end user, to be recorded in the body of the reflog.
925 If this Boolean environment variable is set to false, ignore broken or badly named refs when iterating
926 over lists of refs. Normally Git will try to include any such
927 refs, which may cause some operations to fail. This is usually
928 preferable, as potentially destructive operations (e.g.,
929 linkgit:git-prune[1]) are better off aborting rather than
930 ignoring broken refs (and thus considering the history they
931 point to as not worth saving). The default value is `1` (i.e.,
932 be paranoid about detecting and aborting all operations). You
933 should not normally need to set this to `0`, but it may be
934 useful when trying to salvage data from a corrupted repository.
936 `GIT_COMMIT_GRAPH_PARANOIA`::
937 When loading a commit object from the commit-graph, Git performs an
938 existence check on the object in the object database. This is done to
939 avoid issues with stale commit-graphs that contain references to
940 already-deleted commits, but comes with a performance penalty.
942 The default is "false", which disables the aforementioned behavior.
943 Setting this to "true" enables the existence check so that stale commits
944 will never be returned from the commit-graph at the cost of performance.
946 `GIT_ALLOW_PROTOCOL`::
947 If set to a colon-separated list of protocols, behave as if
948 `protocol.allow` is set to `never`, and each of the listed
949 protocols has `protocol.<name>.allow` set to `always`
950 (overriding any existing configuration). See the description of
951 `protocol.allow` in linkgit:git-config[1] for more details.
953 `GIT_PROTOCOL_FROM_USER`::
954 Set this Boolean environment variable to false to prevent protocols used by fetch/push/clone which are
955 configured to the `user` state. This is useful to restrict recursive
956 submodule initialization from an untrusted repository or for programs
957 which feed potentially-untrusted URLS to git commands. See
958 linkgit:git-config[1] for more details.
961 For internal use only. Used in handshaking the wire protocol.
962 Contains a colon ':' separated list of keys with optional values
963 '<key>[=<value>]'. Presence of unknown keys and values must be
966 Note that servers may need to be configured to allow this variable to
967 pass over some transports. It will be propagated automatically when
968 accessing local repositories (i.e., `file://` or a filesystem path), as
969 well as over the `git://` protocol. For git-over-http, it should work
970 automatically in most configurations, but see the discussion in
971 linkgit:git-http-backend[1]. For git-over-ssh, the ssh server may need
972 to be configured to allow clients to pass this variable (e.g., by using
973 `AcceptEnv GIT_PROTOCOL` with OpenSSH).
975 This configuration is optional. If the variable is not propagated, then
976 clients will fall back to the original "v0" protocol (but may miss out
977 on some performance improvements or features). This variable currently
978 only affects clones and fetches; it is not yet used for pushes (but may
981 `GIT_OPTIONAL_LOCKS`::
982 If this Boolean environment variable is set to false, Git will complete any requested operation without
983 performing any optional sub-operations that require taking a lock.
984 For example, this will prevent `git status` from refreshing the
985 index as a side effect. This is useful for processes running in
986 the background which do not want to cause lock contention with
987 other operations on the repository. Defaults to `1`.
989 `GIT_REDIRECT_STDIN`::
990 `GIT_REDIRECT_STDOUT`::
991 `GIT_REDIRECT_STDERR`::
992 Windows-only: allow redirecting the standard input/output/error
993 handles to paths specified by the environment variables. This is
994 particularly useful in multi-threaded applications where the
995 canonical way to pass standard handles via `CreateProcess()` is
996 not an option because it would require the handles to be marked
997 inheritable (and consequently *every* spawned process would
998 inherit them, possibly blocking regular Git operations). The
999 primary intended use case is to use named pipes for communication
1000 (e.g. `\\.\pipe\my-git-stdin-123`).
1002 Two special values are supported: `off` will simply close the
1003 corresponding standard handle, and if `GIT_REDIRECT_STDERR` is
1004 `2>&1`, standard error will be redirected to the same handle as
1007 `GIT_PRINT_SHA1_ELLIPSIS` (deprecated)::
1008 If set to `yes`, print an ellipsis following an
1009 (abbreviated) SHA-1 value. This affects indications of
1010 detached HEADs (linkgit:git-checkout[1]) and the raw
1011 diff output (linkgit:git-diff[1]). Printing an
1012 ellipsis in the cases mentioned is no longer considered
1013 adequate and support for it is likely to be removed in the
1014 foreseeable future (along with the variable).
1016 Discussion[[Discussion]]
1017 ------------------------
1019 More detail on the following is available from the
1020 link:user-manual.html#git-concepts[Git concepts chapter of the
1021 user-manual] and linkgit:gitcore-tutorial[7].
1023 A Git project normally consists of a working directory with a ".git"
1024 subdirectory at the top level. The .git directory contains, among other
1025 things, a compressed object database representing the complete history
1026 of the project, an "index" file which links that history to the current
1027 contents of the working tree, and named pointers into that history such
1028 as tags and branch heads.
1030 The object database contains objects of three main types: blobs, which
1031 hold file data; trees, which point to blobs and other trees to build up
1032 directory hierarchies; and commits, which each reference a single tree
1033 and some number of parent commits.
1035 The commit, equivalent to what other systems call a "changeset" or
1036 "version", represents a step in the project's history, and each parent
1037 represents an immediately preceding step. Commits with more than one
1038 parent represent merges of independent lines of development.
1040 All objects are named by the SHA-1 hash of their contents, normally
1041 written as a string of 40 hex digits. Such names are globally unique.
1042 The entire history leading up to a commit can be vouched for by signing
1043 just that commit. A fourth object type, the tag, is provided for this
1046 When first created, objects are stored in individual files, but for
1047 efficiency may later be compressed together into "pack files".
1049 Named pointers called refs mark interesting points in history. A ref
1050 may contain the SHA-1 name of an object or the name of another ref (the
1051 latter is called a "symbolic ref").
1052 Refs with names beginning `refs/head/` contain the SHA-1 name of the most
1053 recent commit (or "head") of a branch under development. SHA-1 names of
1054 tags of interest are stored under `refs/tags/`. A symbolic ref named
1055 `HEAD` contains the name of the currently checked-out branch.
1057 The index file is initialized with a list of all paths and, for each
1058 path, a blob object and a set of attributes. The blob object represents
1059 the contents of the file as of the head of the current branch. The
1060 attributes (last modified time, size, etc.) are taken from the
1061 corresponding file in the working tree. Subsequent changes to the
1062 working tree can be found by comparing these attributes. The index may
1063 be updated with new content, and new commits may be created from the
1064 content stored in the index.
1066 The index is also capable of storing multiple entries (called "stages")
1067 for a given pathname. These stages are used to hold the various
1068 unmerged version of a file when a merge is in progress.
1073 Some configuration options and hook files may cause Git to run arbitrary
1074 shell commands. Because configuration and hooks are not copied using
1075 `git clone`, it is generally safe to clone remote repositories with
1076 untrusted content, inspect them with `git log`, and so on.
1078 However, it is not safe to run Git commands in a `.git` directory (or
1079 the working tree that surrounds it) when that `.git` directory itself
1080 comes from an untrusted source. The commands in its config and hooks
1081 are executed in the usual way.
1083 By default, Git will refuse to run when the repository is owned by
1084 someone other than the user running the command. See the entry for
1085 `safe.directory` in linkgit:git-config[1]. While this can help protect
1086 you in a multi-user environment, note that you can also acquire
1087 untrusted repositories that are owned by you (for example, if you
1088 extract a zip file or tarball from an untrusted source). In such cases,
1089 you'd need to "sanitize" the untrusted repository first.
1091 If you have an untrusted `.git` directory, you should first clone it
1092 with `git clone --no-local` to obtain a clean copy. Git does restrict
1093 the set of options and hooks that will be run by `upload-pack`, which
1094 handles the server side of a clone or fetch, but beware that the
1095 surface area for attack against `upload-pack` is large, so this does
1096 carry some risk. The safest thing is to serve the repository as an
1097 unprivileged user (either via linkgit:git-daemon[1], ssh, or using
1098 other tools to change user ids). See the discussion in the `SECURITY`
1099 section of linkgit:git-upload-pack[1].
1101 FURTHER DOCUMENTATION
1102 ---------------------
1104 See the references in the "description" section to get started
1105 using Git. The following is probably more detail than necessary
1106 for a first-time user.
1108 The link:user-manual.html#git-concepts[Git concepts chapter of the
1109 user-manual] and linkgit:gitcore-tutorial[7] both provide
1110 introductions to the underlying Git architecture.
1112 See linkgit:gitworkflows[7] for an overview of recommended workflows.
1114 See also the link:howto-index.html[howto] documents for some useful
1117 The internals are documented in the
1118 link:technical/api-index.html[Git API documentation].
1120 Users migrating from CVS may also want to
1121 read linkgit:gitcvs-migration[7].
1126 Git was started by Linus Torvalds, and is currently maintained by Junio
1127 C Hamano. Numerous contributions have come from the Git mailing list
1128 <git@vger.kernel.org>. https://openhub.net/p/git/contributors/summary
1129 gives you a more complete list of contributors.
1131 If you have a clone of git.git itself, the
1132 output of linkgit:git-shortlog[1] and linkgit:git-blame[1] can show you
1133 the authors for specific parts of the project.
1138 Report bugs to the Git mailing list <git@vger.kernel.org> where the
1139 development and maintenance is primarily done. You do not have to be
1140 subscribed to the list to send a message there. See the list archive
1141 at https://lore.kernel.org/git for previous bug reports and other
1144 Issues which are security relevant should be disclosed privately to
1145 the Git Security mailing list <git-security@googlegroups.com>.
1149 linkgit:gittutorial[7], linkgit:gittutorial-2[7],
1150 linkgit:giteveryday[7], linkgit:gitcvs-migration[7],
1151 linkgit:gitglossary[7], linkgit:gitcore-tutorial[7],
1152 linkgit:gitcli[7], link:user-manual.html[The Git User's Manual],
1153 linkgit:gitworkflows[7]
1157 Part of the linkgit:git[1] suite