interplane.Get Omega
Read in your language

git

[Ported from github.com/git/git] Sync with Git 2.56.1

Brought by drakestapleton

branch master Branches Tags History

git / Documentation / git.adoc

1230 lines · 47640 bytes Raw Blame History
1git(1)
2======
3
4NAME
5----
6git - the stupid content tracker
7
8
9SYNOPSIS
10--------
11[verse]
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] [--no-lazy-fetch]
15 [--no-optional-locks] [--no-advice] [--bare] [--git-dir=<path>]
16 [--work-tree=<path>] [--namespace=<name>] [--config-env=<name>=<envvar>]
17 <command> [<args>]
18
19DESCRIPTION
20-----------
21Git is a fast, scalable, distributed revision control system with an
22unusually rich command set that provides both high-level operations
23and full access to internals.
24
25There are two ways to get help with any Git subcommand (replace "push"
26with the command you want help with):
27
28- `git push -h` for a short help
29- `git push --help` or `git help push` for the full documentation
30
31There are also guides explaining Git's concepts and more:
32
33- `git help` shows the most frequently used Git subcommands
34- `git help --guides` lists Git's concept guides
35- `git help --user-interfaces` lists guides for various
36 special files you can use to change Git's behaviour
37
38You can view an HTML version of the documentation with `git help --web`
39(for example `git help --web push`) or at https://git-scm.com/docs.
40
41OPTIONS
42-------
43-v::
44--version::
45 Prints the Git suite version that the 'git' program came from.
46+
47This option is internally converted to `git version ...` and accepts
48the same options as the linkgit:git-version[1] command. If `--help` is
49also given, it takes precedence over `--version`.
50
51-h::
52--help::
53 Prints the synopsis and a list of the most commonly used
54 commands. If the option `--all` or `-a` is given then all
55 available commands are printed. If a Git command is named this
56 option will bring up the manual page for that command.
57+
58Other options are available to control how the manual page is
59displayed. See linkgit:git-help[1] for more information,
60because `git --help ...` is converted internally into `git
61help ...`.
62
63-C <path>::
64 Run as if git was started in '<path>' instead of the current working
65 directory. When multiple `-C` options are given, each subsequent
66 non-absolute `-C <path>` is interpreted relative to the preceding `-C
67 <path>`. If '<path>' is present but empty, e.g. `-C ""`, then the
68 current working directory is left unchanged.
69+
70This option affects options that expect path name like `--git-dir` and
71`--work-tree` in that their interpretations of the path names would be
72made relative to the working directory caused by the `-C` option. For
73example the following invocations are equivalent:
74
75 git --git-dir=a.git --work-tree=b -C c status
76 git --git-dir=c/a.git --work-tree=c/b status
77
78-c <name>=<value>::
79 Pass a configuration parameter to the command. The value
80 given will override values from configuration files.
81 The <name> is expected in the same format as listed by
82 'git config' (subkeys separated by dots).
83+
84Note that omitting the `=` in `git -c foo.bar ...` is allowed and sets
85`foo.bar` to the boolean true value (just like `[foo]bar` would in a
86config file). Including the equals but with an empty value (like `git -c
87foo.bar= ...`) sets `foo.bar` to the empty string which `git config
88--type=bool` will convert to `false`.
89
90--config-env=<name>=<envvar>::
91 Like `-c <name>=<value>`, give configuration variable
92 '<name>' a value, where <envvar> is the name of an
93 environment variable from which to retrieve the value. Unlike
94 `-c` there is no shortcut for directly setting the value to an
95 empty string, instead the environment variable itself must be
96 set to the empty string. It is an error if the `<envvar>` does not exist
97 in the environment. `<envvar>` may not contain an equals sign
98 to avoid ambiguity with `<name>` containing one.
99+
100This is useful for cases where you want to pass transitory
101configuration options to git, but are doing so on operating systems
102where other processes might be able to read your command line
103(e.g. `/proc/self/cmdline`), but not your environment
104(e.g. `/proc/self/environ`). That behavior is the default on
105Linux, but may not be on your system.
106+
107Note that this might add security for variables such as
108`http.extraHeader` where the sensitive information is part of
109the value, but not e.g. `url.<base>.insteadOf` where the
110sensitive information can be part of the key.
111
112--exec-path[=<path>]::
113 Path to wherever your core Git programs are installed.
114 This can also be controlled by setting the GIT_EXEC_PATH
115 environment variable. If no path is given, 'git' will print
116 the current setting and then exit.
117
118--html-path::
119 Print the path, without trailing slash, where Git's HTML
120 documentation is installed and exit.
121
122--man-path::
123 Print the manpath (see `man(1)`) for the man pages for
124 this version of Git and exit.
125
126--info-path::
127 Print the path where the Info files documenting this
128 version of Git are installed and exit.
129
130-p::
131--paginate::
132 Pipe all output into 'less' (or if set, $PAGER) if standard
133 output is a terminal. This overrides the `pager.<cmd>`
134 configuration options (see the "Configuration Mechanism" section
135 below).
136
137-P::
138--no-pager::
139 Do not pipe Git output into a pager.
140
141--git-dir=<path>::
142 Set the path to the repository (".git" directory). This can also be
143 controlled by setting the `GIT_DIR` environment variable. It can be
144 an absolute path or relative path to current working directory.
145+
146Specifying the location of the ".git" directory using this
147option (or `GIT_DIR` environment variable) turns off the
148repository discovery that tries to find a directory with
149".git" subdirectory (which is how the repository and the
150top-level of the working tree are discovered), and tells Git
151that you are at the top level of the working tree. If you
152are not at the top-level directory of the working tree, you
153should tell Git where the top-level of the working tree is,
154with the `--work-tree=<path>` option (or `GIT_WORK_TREE`
155environment variable)
156+
157If you just want to run git as if it was started in `<path>` then use
158`git -C <path>`.
159
160--work-tree=<path>::
161 Set the path to the working tree. It can be an absolute path
162 or a path relative to the current working directory.
163 This can also be controlled by setting the GIT_WORK_TREE
164 environment variable and the core.worktree configuration
165 variable (see core.worktree in linkgit:git-config[1] for a
166 more detailed discussion).
167
168--namespace=<path>::
169 Set the Git namespace. See linkgit:gitnamespaces[7] for more
170 details. Equivalent to setting the `GIT_NAMESPACE` environment
171 variable.
172
173--bare::
174 Treat the repository as a bare repository. If GIT_DIR
175 environment is not set, it is set to the current working
176 directory.
177
178--no-replace-objects::
179 Do not use replacement refs to replace Git objects.
180 This is equivalent to exporting the `GIT_NO_REPLACE_OBJECTS`
181 environment variable with any value.
182 See linkgit:git-replace[1] for more information.
183
184--no-lazy-fetch::
185 Do not fetch missing objects from the promisor remote on
186 demand. Useful together with `git cat-file -e <object>` to
187 see if the object is locally available.
188 This is equivalent to setting the `GIT_NO_LAZY_FETCH`
189 environment variable to `1`.
190
191--no-optional-locks::
192 Do not perform optional operations that require locks. This is
193 equivalent to setting the `GIT_OPTIONAL_LOCKS` to `0`.
194
195--no-advice::
196 Disable all advice hints from being printed.
197
198--literal-pathspecs::
199 Treat pathspecs literally (i.e. no globbing, no pathspec magic).
200 This is equivalent to setting the `GIT_LITERAL_PATHSPECS` environment
201 variable to `1`.
202
203--glob-pathspecs::
204 Add "glob" magic to all pathspec. This is equivalent to setting
205 the `GIT_GLOB_PATHSPECS` environment variable to `1`. Disabling
206 globbing on individual pathspecs can be done using pathspec
207 magic ":(literal)"
208
209--noglob-pathspecs::
210 Add "literal" magic to all pathspec. This is equivalent to setting
211 the `GIT_NOGLOB_PATHSPECS` environment variable to `1`. Enabling
212 globbing on individual pathspecs can be done using pathspec
213 magic ":(glob)"
214
215--icase-pathspecs::
216 Add "icase" magic to all pathspec. This is equivalent to setting
217 the `GIT_ICASE_PATHSPECS` environment variable to `1`.
218
219--list-cmds=<group>[,<group>...]::
220 List commands by group. This is an internal/experimental
221 option and may change or be removed in the future. Supported
222 groups are: builtins, parseopt (builtin commands that use
223 parse-options), deprecated (deprecated builtins),
224 main (all commands in libexec directory),
225 others (all other commands in `$PATH` that have git- prefix),
226 list-<category> (see categories in command-list.txt),
227 nohelpers (exclude helper commands), alias and config
228 (retrieve command list from config variable completion.commands)
229
230--attr-source=<tree-ish>::
231 Read gitattributes from <tree-ish> instead of the worktree. See
232 linkgit:gitattributes[5]. This is equivalent to setting the
233 `GIT_ATTR_SOURCE` environment variable.
234
235GIT COMMANDS
236------------
237
238We divide Git into high level ("porcelain") commands and low level
239("plumbing") commands. For defining command aliases, see
240linkgit:git-config[1] and look for descriptions of `alias.*`.
241For installing custom "git" subcommands, see the description for
242the 'PATH' environment variable in this manual.
243
244High-level commands (porcelain)
245-------------------------------
246
247We separate the porcelain commands into the main commands and some
248ancillary user utilities.
249
250Main porcelain commands
251~~~~~~~~~~~~~~~~~~~~~~~
252
253include::{build_dir}/cmds-mainporcelain.adoc[]
254
255Ancillary Commands
256~~~~~~~~~~~~~~~~~~
257Manipulators:
258
259include::{build_dir}/cmds-ancillarymanipulators.adoc[]
260
261Interrogators:
262
263include::{build_dir}/cmds-ancillaryinterrogators.adoc[]
264
265
266Interacting with Others
267~~~~~~~~~~~~~~~~~~~~~~~
268
269These commands are to interact with foreign SCM and with other
270people via patch over e-mail.
271
272include::{build_dir}/cmds-foreignscminterface.adoc[]
273
274Reset, restore and revert
275~~~~~~~~~~~~~~~~~~~~~~~~~
276There are three commands with similar names: `git reset`,
277`git restore` and `git revert`.
278
279* linkgit:git-revert[1] is about making a new commit that reverts the
280 changes made by other commits.
281
282* linkgit:git-restore[1] is about restoring files in the working tree
283 from either the index or another commit. This command does not
284 update your branch. The command can also be used to restore files in
285 the index from another commit.
286
287* linkgit:git-reset[1] is about updating your branch, moving the tip
288 in order to add or remove commits from the branch. This operation
289 changes the commit history.
290+
291`git reset` can also be used to restore the index, overlapping with
292`git restore`.
293
294
295Low-level commands (plumbing)
296-----------------------------
297
298Although Git includes its
299own porcelain layer, its low-level commands are sufficient to support
300development of alternative porcelains. Developers of such porcelains
301might start by reading about linkgit:git-update-index[1] and
302linkgit:git-read-tree[1].
303
304The interface (input, output, set of options and the semantics)
305to these low-level commands are meant to be a lot more stable
306than Porcelain level commands, because these commands are
307primarily for scripted use. The interface to Porcelain commands
308on the other hand are subject to change in order to improve the
309end user experience.
310
311The following description divides
312the low-level commands into commands that manipulate objects (in
313the repository, index, and working tree), commands that interrogate and
314compare objects, and commands that move objects and references between
315repositories.
316
317
318Manipulation commands
319~~~~~~~~~~~~~~~~~~~~~
320
321include::{build_dir}/cmds-plumbingmanipulators.adoc[]
322
323
324Interrogation commands
325~~~~~~~~~~~~~~~~~~~~~~
326
327include::{build_dir}/cmds-plumbinginterrogators.adoc[]
328
329In general, the interrogate commands do not touch the files in
330the working tree.
331
332
333Syncing repositories
334~~~~~~~~~~~~~~~~~~~~
335
336include::{build_dir}/cmds-synchingrepositories.adoc[]
337
338The following are helper commands used by the above; end users
339typically do not use them directly.
340
341include::{build_dir}/cmds-synchelpers.adoc[]
342
343
344Internal helper commands
345~~~~~~~~~~~~~~~~~~~~~~~~
346
347These are internal helper commands used by other commands; end
348users typically do not use them directly.
349
350include::{build_dir}/cmds-purehelpers.adoc[]
351
352Guides
353------
354
355The following documentation pages are guides about Git concepts.
356
357include::{build_dir}/cmds-guide.adoc[]
358
359Repository, command and file interfaces
360---------------------------------------
361
362This documentation discusses repository and command interfaces which
363users are expected to interact with directly. See `--user-formats` in
364linkgit:git-help[1] for more details on the criteria.
365
366include::{build_dir}/cmds-userinterfaces.adoc[]
367
368File formats, protocols and other developer interfaces
369------------------------------------------------------
370
371This documentation discusses file formats, over-the-wire protocols and
372other git developer interfaces. See `--developer-interfaces` in
373linkgit:git-help[1].
374
375include::{build_dir}/cmds-developerinterfaces.adoc[]
376
377Configuration Mechanism
378-----------------------
379
380Git uses a simple text format to store customizations that are per
381repository and are per user. Such a configuration file may look
382like this:
383
384------------
385#
386# A '#' or ';' character indicates a comment.
387#
388
389; core variables
390[core]
391 ; Don't trust file modes
392 filemode = false
393
394; user identity
395[user]
396 name = "Junio C Hamano"
397 email = "gitster@pobox.com"
398
399------------
400
401Various commands read from the configuration file and adjust
402their operation accordingly. See linkgit:git-config[1] for a
403list and more details about the configuration mechanism.
404
405
406Identifier Terminology
407----------------------
408<object>::
409 Indicates the object name for any type of object.
410
411<blob>::
412 Indicates a blob object name.
413
414<tree>::
415 Indicates a tree object name.
416
417<commit>::
418 Indicates a commit object name.
419
420<tree-ish>::
421 Indicates a tree, commit or tag object name. A
422 command that takes a <tree-ish> argument ultimately wants to
423 operate on a <tree> object but automatically dereferences
424 <commit> and <tag> objects that point at a <tree>.
425
426<commit-ish>::
427 Indicates a commit or tag object name. A
428 command that takes a <commit-ish> argument ultimately wants to
429 operate on a <commit> object but automatically dereferences
430 <tag> objects that point at a <commit>.
431
432<type>::
433 Indicates that an object type is required.
434 Currently one of: `blob`, `tree`, `commit`, or `tag`.
435
436<file>::
437 Indicates a filename - almost always relative to the
438 root of the tree structure `GIT_INDEX_FILE` describes.
439
440Symbolic Identifiers
441--------------------
442Any Git command accepting any <object> can also use the following
443symbolic notation:
444
445HEAD::
446 indicates the head of the current branch.
447
448<tag>::
449 a valid tag 'name'
450 (i.e. a `refs/tags/<tag>` reference).
451
452<head>::
453 a valid head 'name'
454 (i.e. a `refs/heads/<head>` reference).
455
456For a more complete list of ways to spell object names, see
457"SPECIFYING REVISIONS" section in linkgit:gitrevisions[7].
458
459
460File/Directory Structure
461------------------------
462
463Please see the linkgit:gitrepository-layout[5] document.
464
465Read linkgit:githooks[5] for more details about each hook.
466
467Higher level SCMs may provide and manage additional information in the
468`$GIT_DIR`.
469
470
471Terminology
472-----------
473Please see linkgit:gitglossary[7]. See linkgit:gitdatamodel[7] for a
474discussion of the core data model, which includes important terminology
475used throughout the documentation.
476
477
478Environment Variables
479---------------------
480Various Git commands pay attention to environment variables and change
481their behavior. The environment variables marked as "Boolean" take
482their values the same way as Boolean valued configuration variables, i.e.,
483"true", "yes", "on" and positive numbers are taken as "yes", while "false",
484"no", "off", and "0" are taken as "no".
485
486Here are the variables:
487
488System
489~~~~~~
490`HOME`::
491 Specifies the path to the user's home directory. On Windows, if
492 unset, Git will set a process environment variable equal to:
493 `$HOMEDRIVE$HOMEPATH` if both `$HOMEDRIVE` and `$HOMEPATH` exist;
494 otherwise `$USERPROFILE` if `$USERPROFILE` exists.
495
496`PATH`::
497 When a user runs 'git <command>' that is not part of the core Git programs
498 (installed in GIT_EXEC_PATH), 'git-<command>' that is runnable by the user
499 in a directory on `$PATH` is invoked. Argument passed after the command
500 name are passed as-is to the program. To execute `git <foo>`, `git` finds
501 command `<foo>` (either a core Git program found in 'GIT_EXEC_PATH', or a
502 custom one in a directory on 'PATH'), before trying `foo` as an alias.
503
504The Git Repository
505~~~~~~~~~~~~~~~~~~
506These environment variables apply to 'all' core Git commands. Nb: it
507is worth noting that they may be used/overridden by SCMS sitting above
508Git so take care if using a foreign front-end.
509
510`GIT_INDEX_FILE`::
511 This environment variable specifies an alternate
512 index file. If not specified, the default of `$GIT_DIR/index`
513 is used.
514
515`GIT_INDEX_VERSION`::
516 This environment variable specifies what index version is used
517 when writing the index file out. It won't affect existing index
518 files. By default index file version 2 or 3 is used. See
519 linkgit:git-update-index[1] for more information.
520
521`GIT_OBJECT_DIRECTORY`::
522 If the object storage directory is specified via this
523 environment variable then the sha1 directories are created
524 underneath - otherwise the default `$GIT_DIR/objects`
525 directory is used.
526
527`GIT_ALTERNATE_OBJECT_DIRECTORIES`::
528 Due to the immutable nature of Git objects, old objects can be
529 archived into shared, read-only directories. This variable
530 specifies a ":" separated (on Windows ";" separated) list
531 of Git object directories which can be used to search for Git
532 objects. New objects will not be written to these directories.
533+
534Entries that begin with `"` (double-quote) will be interpreted
535as C-style quoted paths, removing leading and trailing
536double-quotes and respecting backslash escapes. E.g., the value
537`"path-with-\"-and-:-in-it":vanilla-path` has two paths:
538`path-with-"-and-:-in-it` and `vanilla-path`.
539
540`GIT_DIR`::
541 If the `GIT_DIR` environment variable is set then it
542 specifies a path to use instead of the default `.git`
543 for the base of the repository.
544 The `--git-dir` command-line option also sets this value.
545
546`GIT_WORK_TREE`::
547 Set the path to the root of the working tree.
548 This can also be controlled by the `--work-tree` command-line
549 option and the core.worktree configuration variable.
550
551`GIT_NAMESPACE`::
552 Set the Git namespace; see linkgit:gitnamespaces[7] for details.
553 The `--namespace` command-line option also sets this value.
554
555`GIT_CEILING_DIRECTORIES`::
556 This should be a colon-separated list of absolute paths. If
557 set, it is a list of directories that Git should not chdir up
558 into while looking for a repository directory (useful for
559 excluding slow-loading network directories). It will not
560 exclude the current working directory or a GIT_DIR set on the
561 command line or in the environment. Normally, Git has to read
562 the entries in this list and resolve any symlink that
563 might be present in order to compare them with the current
564 directory. However, if even this access is slow, you
565 can add an empty entry to the list to tell Git that the
566 subsequent entries are not symlinks and needn't be resolved;
567 e.g.,
568 `GIT_CEILING_DIRECTORIES=/maybe/symlink::/very/slow/non/symlink`.
569
570`GIT_DISCOVERY_ACROSS_FILESYSTEM`::
571 When run in a directory that does not have ".git" repository
572 directory, Git tries to find such a directory in the parent
573 directories to find the top of the working tree, but by default it
574 does not cross filesystem boundaries. This Boolean environment variable
575 can be set to true to tell Git not to stop at filesystem
576 boundaries. Like `GIT_CEILING_DIRECTORIES`, this will not affect
577 an explicit repository directory set via `GIT_DIR` or on the
578 command line.
579
580`GIT_COMMON_DIR`::
581 If this variable is set to a path, non-worktree files that are
582 normally in $GIT_DIR will be taken from this path
583 instead. Worktree-specific files such as HEAD or index are
584 taken from $GIT_DIR. See linkgit:gitrepository-layout[5] and
585 linkgit:git-worktree[1] for
586 details. This variable has lower precedence than other path
587 variables such as GIT_INDEX_FILE, GIT_OBJECT_DIRECTORY...
588
589`GIT_DEFAULT_HASH`::
590 If this variable is set, the default hash algorithm for new
591 repositories will be set to this value. This value is
592 ignored when cloning and the setting of the remote repository
593 is always used. The default is "sha1".
594 See `--object-format` in linkgit:git-init[1].
595
596`GIT_DEFAULT_REF_STORAGE_FORMAT`::
597 If this variable is set, the default ref storage format for new
598 repositories will be set to this value. The default is "files".
599 See `--ref-storage-format` in linkgit:git-init[1].
600
601`GIT_DEFAULT_REF_FORMAT`::
602 Deprecated alias of `GIT_DEFAULT_REF_STORAGE_FORMAT`.
603
604`GIT_REF_STORAGE_FORMAT`::
605 Specify which ref storage format to use along with its URI.
606 See `extensions.refStorage` option in linkgit:git-config[1] for more
607 details. Overrides the config variable when used.
608
609`GIT_REFERENCE_BACKEND`::
610 Deprecated alias of `GIT_REF_STORAGE_FORMAT`.
611
612`GIT_DEFAULT_OBJECT_STORAGE_FORMAT`::
613 If this variable is set, the default object storage format for new
614 repositories will be set to this value. The default is "files".
615 See `--object-storage-format` in linkgit:git-init[1].
616
617`GIT_OBJECT_STORAGE_FORMAT`::
618 Specify which object storage format to use along with its URI.
619 See `extensions.objectStorage` option in linkgit:git-config[1] for more
620 details. Overrides the config variable when used.
621
622Git Commits
623~~~~~~~~~~~
624`GIT_AUTHOR_NAME`::
625 The human-readable name used in the author identity when creating commit or
626 tag objects, or when writing reflogs. Overrides the `user.name` and
627 `author.name` configuration settings.
628
629`GIT_AUTHOR_EMAIL`::
630 The email address used in the author identity when creating commit or
631 tag objects, or when writing reflogs. Overrides the `user.email` and
632 `author.email` configuration settings.
633
634`GIT_AUTHOR_DATE`::
635 The date used for the author identity when creating commit or tag objects, or
636 when writing reflogs. See linkgit:git-commit[1] for valid formats.
637
638`GIT_COMMITTER_NAME`::
639 The human-readable name used in the committer identity when creating commit or
640 tag objects, or when writing reflogs. Overrides the `user.name` and
641 `committer.name` configuration settings.
642
643`GIT_COMMITTER_EMAIL`::
644 The email address used in the author identity when creating commit or
645 tag objects, or when writing reflogs. Overrides the `user.email` and
646 `committer.email` configuration settings.
647
648`GIT_COMMITTER_DATE`::
649 The date used for the committer identity when creating commit or tag objects, or
650 when writing reflogs. See linkgit:git-commit[1] for valid formats.
651
652`EMAIL`::
653 The email address used in the author and committer identities if no other
654 relevant environment variable or configuration setting has been set.
655
656Git Diffs
657~~~~~~~~~
658`GIT_DIFF_OPTS`::
659 Only valid setting is "--unified=??" or "-u??" to set the
660 number of context lines shown when a unified diff is created.
661 This takes precedence over any "-U" or "--unified" option
662 value passed on the Git diff command line.
663
664`GIT_EXTERNAL_DIFF`::
665 When the environment variable `GIT_EXTERNAL_DIFF` is set, the
666 program named by it is called to generate diffs, and Git
667 does not use its builtin diff machinery.
668 For a path that is added, removed, or modified,
669 `GIT_EXTERNAL_DIFF` is called with 7 parameters:
670
671 path old-file old-hex old-mode new-file new-hex new-mode
672+
673where:
674
675 <old|new>-file:: are files GIT_EXTERNAL_DIFF can use to read the
676 contents of <old|new>,
677 <old|new>-hex:: are the 40-hexdigit SHA-1 hashes,
678 <old|new>-mode:: are the octal representation of the file modes.
679+
680The file parameters can point at the user's working file
681(e.g. `new-file` in "git-diff-files"), `/dev/null` (e.g. `old-file`
682when a new file is added), or a temporary file (e.g. `old-file` in the
683index). `GIT_EXTERNAL_DIFF` should not worry about unlinking the
684temporary file -- it is removed when `GIT_EXTERNAL_DIFF` exits.
685+
686For a path that is unmerged, `GIT_EXTERNAL_DIFF` is called with 1
687parameter, <path>.
688+
689For each path `GIT_EXTERNAL_DIFF` is called, two environment variables,
690`GIT_DIFF_PATH_COUNTER` and `GIT_DIFF_PATH_TOTAL` are set.
691
692`GIT_EXTERNAL_DIFF_TRUST_EXIT_CODE`::
693 If this Boolean environment variable is set to true then the
694 `GIT_EXTERNAL_DIFF` command is expected to return exit code
695 0 if it considers the input files to be equal or 1 if it
696 considers them to be different, like `diff(1)`.
697 If it is set to false, which is the default, then the command
698 is expected to return exit code 0 regardless of equality.
699 Any other exit code causes Git to report a fatal error.
700
701
702`GIT_DIFF_PATH_COUNTER`::
703 A 1-based counter incremented by one for every path.
704
705`GIT_DIFF_PATH_TOTAL`::
706 The total number of paths.
707
708other
709~~~~~
710`GIT_MERGE_VERBOSITY`::
711 A number controlling the amount of output shown by
712 the recursive merge strategy. Overrides merge.verbosity.
713 See linkgit:git-merge[1]
714
715`GIT_PAGER`::
716 This environment variable overrides `$PAGER`. If it is set
717 to an empty string or to the value "cat", Git will not launch
718 a pager. See also the `core.pager` option in
719 linkgit:git-config[1].
720
721`GIT_PROGRESS_DELAY`::
722 A number controlling how many seconds to delay before showing
723 optional progress indicators. Defaults to 1.
724
725`GIT_EDITOR`::
726 This environment variable overrides `$EDITOR` and `$VISUAL`.
727 It is used by several Git commands when, on interactive mode,
728 an editor is to be launched. See also linkgit:git-var[1]
729 and the `core.editor` option in linkgit:git-config[1].
730
731`GIT_SEQUENCE_EDITOR`::
732 This environment variable overrides the configured Git editor
733 when editing the todo list of an interactive rebase. See also
734 linkgit:git-rebase[1] and the `sequence.editor` option in
735 linkgit:git-config[1].
736
737`GIT_SSH`::
738`GIT_SSH_COMMAND`::
739 If either of these environment variables is set then 'git fetch'
740 and 'git push' will use the specified command instead of 'ssh'
741 when they need to connect to a remote system.
742 The command-line parameters passed to the configured command are
743 determined by the ssh variant. See `ssh.variant` option in
744 linkgit:git-config[1] for details.
745+
746`$GIT_SSH_COMMAND` takes precedence over `$GIT_SSH`, and is interpreted
747by the shell, which allows additional arguments to be included.
748`$GIT_SSH` on the other hand must be just the path to a program
749(which can be a wrapper shell script, if additional arguments are
750needed).
751+
752Usually it is easier to configure any desired options through your
753personal `.ssh/config` file. Please consult your ssh documentation
754for further details.
755
756`GIT_SSH_VARIANT`::
757 If this environment variable is set, it overrides Git's autodetection
758 whether `GIT_SSH`/`GIT_SSH_COMMAND`/`core.sshCommand` refer to OpenSSH,
759 plink or tortoiseplink. This variable overrides the config setting
760 `ssh.variant` that serves the same purpose.
761
762`GIT_SSL_NO_VERIFY`::
763 Setting and exporting this environment variable to any value
764 tells Git not to verify the SSL certificate when fetching or
765 pushing over HTTPS.
766
767`GIT_ATTR_SOURCE`::
768 Sets the treeish that gitattributes will be read from.
769
770`GIT_ASKPASS`::
771 If this environment variable is set, then Git commands which need to
772 acquire passwords or passphrases (e.g. for HTTP or IMAP authentication)
773 will call this program with a suitable prompt as command-line argument
774 and read the password from its STDOUT. See also the `core.askPass`
775 option in linkgit:git-config[1].
776
777`GIT_TERMINAL_PROMPT`::
778 If this Boolean environment variable is set to false, git will not prompt
779 on the terminal (e.g., when asking for HTTP authentication).
780
781`GIT_CONFIG_GLOBAL`::
782`GIT_CONFIG_SYSTEM`::
783 Take the configuration from the given files instead from global or
784 system-level configuration files. If `GIT_CONFIG_SYSTEM` is set, the
785 system config file defined at build time (usually `/etc/gitconfig`)
786 will not be read. Likewise, if `GIT_CONFIG_GLOBAL` is set, neither
787 `$HOME/.gitconfig` nor `$XDG_CONFIG_HOME/git/config` will be read. Can
788 be set to `/dev/null` to skip reading configuration files of the
789 respective level.
790
791`GIT_CONFIG_NOSYSTEM`::
792 Whether to skip reading settings from the system-wide
793 `$(prefix)/etc/gitconfig` file. This Boolean environment variable can
794 be used along with `$HOME` and `$XDG_CONFIG_HOME` to create a
795 predictable environment for a picky script, or you can set it
796 to true to temporarily avoid using a buggy `/etc/gitconfig` file while
797 waiting for someone with sufficient permissions to fix it.
798
799`GIT_FLUSH`::
800 If this Boolean environment variable is set to true, then commands such
801 as 'git blame' (in incremental mode), 'git rev-list', 'git log',
802 'git check-attr' and 'git check-ignore' will
803 force a flush of the output stream after each record have been
804 flushed. If this
805 variable is set to false, the output of these commands will be done
806 using completely buffered I/O. If this environment variable is
807 not set, Git will choose buffered or record-oriented flushing
808 based on whether stdout appears to be redirected to a file or not.
809
810`GIT_TRACE`::
811 Enables general trace messages, e.g. alias expansion, built-in
812 command execution and external command execution.
813+
814If this variable is set to "1", "2" or "true" (comparison
815is case insensitive), trace messages will be printed to
816stderr.
817+
818If the variable is set to an integer value greater than 2
819and lower than 10 (strictly) then Git will interpret this
820value as an open file descriptor and will try to write the
821trace messages into this file descriptor.
822+
823Alternatively, if the variable is set to an absolute path
824(starting with a '/' character), Git will interpret this
825as a file path and will try to append the trace messages
826to it.
827+
828Unsetting the variable, or setting it to empty, "0" or
829"false" (case insensitive) disables trace messages.
830
831`GIT_TRACE_FSMONITOR`::
832 Enables trace messages for the filesystem monitor extension.
833 See `GIT_TRACE` for available trace output options.
834
835`GIT_TRACE_PACK_ACCESS`::
836 Enables trace messages for all accesses to any packs. For each
837 access, the pack file name and an offset in the pack is
838 recorded. This may be helpful for troubleshooting some
839 pack-related performance problems.
840 See `GIT_TRACE` for available trace output options.
841
842`GIT_TRACE_PACKET`::
843 Enables trace messages for all packets coming in or out of a
844 given program. This can help with debugging object negotiation
845 or other protocol issues. Tracing is turned off at a packet
846 starting with "PACK" (but see `GIT_TRACE_PACKFILE` below).
847 See `GIT_TRACE` for available trace output options.
848
849`GIT_TRACE_PACKFILE`::
850 Enables tracing of packfiles sent or received by a
851 given program. Unlike other trace output, this trace is
852 verbatim: no headers, and no quoting of binary data. You almost
853 certainly want to direct into a file (e.g.,
854 `GIT_TRACE_PACKFILE=/tmp/my.pack`) rather than displaying it on
855 the terminal or mixing it with other trace output.
856+
857Note that this is currently only implemented for the client side
858of clones and fetches.
859
860`GIT_TRACE_PERFORMANCE`::
861 Enables performance related trace messages, e.g. total execution
862 time of each Git command.
863 See `GIT_TRACE` for available trace output options.
864
865`GIT_TRACE_REFS`::
866 Enables trace messages for operations on the ref database.
867 See `GIT_TRACE` for available trace output options.
868
869`GIT_TRACE_SETUP`::
870 Enables trace messages printing the .git, working tree and current
871 working directory after Git has completed its setup phase.
872 See `GIT_TRACE` for available trace output options.
873
874`GIT_TRACE_SHALLOW`::
875 Enables trace messages that can help debugging fetching /
876 cloning of shallow repositories.
877 See `GIT_TRACE` for available trace output options.
878
879`GIT_TRACE_CURL`::
880 Enables a curl full trace dump of all incoming and outgoing data,
881 including descriptive information, of the git transport protocol.
882 This is similar to doing curl `--trace-ascii` on the command line.
883 See `GIT_TRACE` for available trace output options.
884
885`GIT_TRACE_CURL_NO_DATA`::
886 When a curl trace is enabled (see `GIT_TRACE_CURL` above), do not dump
887 data (that is, only dump info lines and headers).
888
889`GIT_TRACE2`::
890 Enables more detailed trace messages from the "trace2" library.
891 Output from `GIT_TRACE2` is a simple text-based format for human
892 readability.
893+
894If this variable is set to "1", "2" or "true" (comparison
895is case insensitive), trace messages will be printed to
896stderr.
897+
898If the variable is set to an integer value greater than 2
899and lower than 10 (strictly) then Git will interpret this
900value as an open file descriptor and will try to write the
901trace messages into this file descriptor.
902+
903Alternatively, if the variable is set to an absolute path
904(starting with a '/' character), Git will interpret this
905as a file path and will try to append the trace messages
906to it. If the path already exists and is a directory, the
907trace messages will be written to files (one per process)
908in that directory, named according to the last component
909of the SID and an optional counter (to avoid filename
910collisions).
911+
912In addition, if the variable is set to
913`af_unix:[<socket-type>:]<absolute-pathname>`, Git will try
914to open the path as a Unix Domain Socket. The socket type
915can be either `stream` or `dgram`.
916+
917Unsetting the variable, or setting it to empty, "0" or
918"false" (case insensitive) disables trace messages.
919+
920See link:technical/api-trace2.html[Trace2 documentation]
921for full details.
922
923
924`GIT_TRACE2_EVENT`::
925 This setting writes a JSON-based format that is suited for machine
926 interpretation.
927 See `GIT_TRACE2` for available trace output options and
928 link:technical/api-trace2.html[Trace2 documentation] for full details.
929
930`GIT_TRACE2_PERF`::
931 In addition to the text-based messages available in `GIT_TRACE2`, this
932 setting writes a column-based format for understanding nesting
933 regions.
934 See `GIT_TRACE2` for available trace output options and
935 link:technical/api-trace2.html[Trace2 documentation] for full details.
936
937`GIT_TRACE_REDACT`::
938 By default, when tracing is activated, Git redacts the values of
939 cookies, the "Authorization:" header, the "Proxy-Authorization:"
940 header and packfile URIs. Set this Boolean environment variable to false to prevent this
941 redaction.
942
943`GIT_NO_REPLACE_OBJECTS`::
944 Setting and exporting this environment variable tells Git to
945 ignore replacement refs and do not replace Git objects.
946
947`GIT_LITERAL_PATHSPECS`::
948 Setting this Boolean environment variable to true will cause Git to treat all
949 pathspecs literally, rather than as glob patterns. For example,
950 running `GIT_LITERAL_PATHSPECS=1 git log -- '*.c'` will search
951 for commits that touch the path `*.c`, not any paths that the
952 glob `*.c` matches. You might want this if you are feeding
953 literal paths to Git (e.g., paths previously given to you by
954 `git ls-tree`, `--raw` diff output, etc).
955
956`GIT_GLOB_PATHSPECS`::
957 Setting this Boolean environment variable to true will cause Git to treat all
958 pathspecs as glob patterns (aka "glob" magic).
959
960`GIT_NOGLOB_PATHSPECS`::
961 Setting this Boolean environment variable to true will cause Git to treat all
962 pathspecs as literal (aka "literal" magic).
963
964`GIT_ICASE_PATHSPECS`::
965 Setting this Boolean environment variable to true will cause Git to treat all
966 pathspecs as case-insensitive.
967
968`GIT_NO_LAZY_FETCH`::
969 Setting this Boolean environment variable to true tells Git
970 not to lazily fetch missing objects from the promisor remote
971 on demand. On the server side, the `uploadpack.lazyFetchTrusted`
972 configuration variable can control this per-repository. See
973 linkgit:git-upload-pack[1].
974
975`GIT_REFLOG_ACTION`::
976 When a ref is updated, reflog entries are created to keep
977 track of the reason why the ref was updated (which is
978 typically the name of the high-level command that updated
979 the ref), in addition to the old and new values of the ref.
980 A scripted Porcelain command can use set_reflog_action
981 helper function in `git-sh-setup` to set its name to this
982 variable when it is invoked as the top level command by the
983 end user, to be recorded in the body of the reflog.
984
985`GIT_REF_PARANOIA`::
986 If this Boolean environment variable is set to false, ignore broken or badly named refs when iterating
987 over lists of refs. Normally Git will try to include any such
988 refs, which may cause some operations to fail. This is usually
989 preferable, as potentially destructive operations (e.g.,
990 linkgit:git-prune[1]) are better off aborting rather than
991 ignoring broken refs (and thus considering the history they
992 point to as not worth saving). The default value is `1` (i.e.,
993 be paranoid about detecting and aborting all operations). You
994 should not normally need to set this to `0`, but it may be
995 useful when trying to salvage data from a corrupted repository.
996
997`GIT_COMMIT_GRAPH_PARANOIA`::
998 When loading a commit object from the commit-graph, Git performs an
999 existence check on the object in the object database. This is done to
1000 avoid issues with stale commit-graphs that contain references to
1001 already-deleted commits, but comes with a performance penalty.
1002+
1003The default is "false", which disables the aforementioned behavior.
1004Setting this to "true" enables the existence check so that stale commits
1005will never be returned from the commit-graph at the cost of performance.
1006
1007`GIT_ALLOW_PROTOCOL`::
1008 If set to a colon-separated list of protocols, behave as if
1009 `protocol.allow` is set to `never`, and each of the listed
1010 protocols has `protocol.<name>.allow` set to `always`
1011 (overriding any existing configuration). See the description of
1012 `protocol.allow` in linkgit:git-config[1] for more details.
1013
1014`GIT_PROTOCOL_FROM_USER`::
1015 Set this Boolean environment variable to false to prevent protocols used by fetch/push/clone which are
1016 configured to the `user` state. This is useful to restrict recursive
1017 submodule initialization from an untrusted repository or for programs
1018 which feed potentially-untrusted URLS to git commands. See
1019 linkgit:git-config[1] for more details.
1020
1021`GIT_PROTOCOL`::
1022 For internal use only. Used in handshaking the wire protocol.
1023 Contains a colon ':' separated list of keys with optional values
1024 '<key>[=<value>]'. Presence of unknown keys and values must be
1025 ignored.
1026+
1027Note that servers may need to be configured to allow this variable to
1028pass over some transports. It will be propagated automatically when
1029accessing local repositories (i.e., `file://` or a filesystem path), as
1030well as over the `git://` protocol. For git-over-http, it should work
1031automatically in most configurations, but see the discussion in
1032linkgit:git-http-backend[1]. For git-over-ssh, the ssh server may need
1033to be configured to allow clients to pass this variable (e.g., by using
1034`AcceptEnv GIT_PROTOCOL` with OpenSSH).
1035+
1036This configuration is optional. If the variable is not propagated, then
1037clients will fall back to the original "v0" protocol (but may miss out
1038on some performance improvements or features). This variable currently
1039only affects clones and fetches; it is not yet used for pushes (but may
1040be in the future).
1041
1042`GIT_OPTIONAL_LOCKS`::
1043 If this Boolean environment variable is set to false, Git will complete any requested operation without
1044 performing any optional sub-operations that require taking a lock.
1045 For example, this will prevent `git status` from refreshing the
1046 index as a side effect. This is useful for processes running in
1047 the background which do not want to cause lock contention with
1048 other operations on the repository. Defaults to `1`.
1049
1050`GIT_REDIRECT_STDIN`::
1051`GIT_REDIRECT_STDOUT`::
1052`GIT_REDIRECT_STDERR`::
1053 Windows-only: allow redirecting the standard input/output/error
1054 handles to paths specified by the environment variables. This is
1055 particularly useful in multi-threaded applications where the
1056 canonical way to pass standard handles via `CreateProcess()` is
1057 not an option because it would require the handles to be marked
1058 inheritable (and consequently *every* spawned process would
1059 inherit them, possibly blocking regular Git operations). The
1060 primary intended use case is to use named pipes for communication
1061 (e.g. `\\.\pipe\my-git-stdin-123`).
1062+
1063Two special values are supported: `off` will simply close the
1064corresponding standard handle, and if `GIT_REDIRECT_STDERR` is
1065`2>&1`, standard error will be redirected to the same handle as
1066standard output.
1067
1068`GIT_PRINT_SHA1_ELLIPSIS` (deprecated)::
1069 If set to `yes`, print an ellipsis following an
1070 (abbreviated) SHA-1 value. This affects indications of
1071 detached HEADs (linkgit:git-checkout[1]) and the raw
1072 diff output (linkgit:git-diff[1]). Printing an
1073 ellipsis in the cases mentioned is no longer considered
1074 adequate and support for it is likely to be removed in the
1075 foreseeable future (along with the variable).
1076
1077`GIT_ADVICE`::
1078 If set to `0`, then disable all advice messages. These messages are
1079 intended to provide hints to human users that may help them get out of
1080 problematic situations or take advantage of new features. Users can
1081 disable individual messages using the `advice.*` config keys. These
1082 messages may be disruptive to tools that execute Git processes, so this
1083 variable is available to disable the messages. (The `--no-advice`
1084 global option is also available, but old Git versions may fail when
1085 this option is not understood. The environment variable will be ignored
1086 by Git versions that do not understand it.)
1087
1088Discussion[[Discussion]]
1089------------------------
1090
1091More detail on the following is available from the
1092link:user-manual.html#git-concepts[Git concepts chapter of the
1093user-manual] and linkgit:gitcore-tutorial[7].
1094
1095A Git project normally consists of a working directory with a ".git"
1096subdirectory at the top level. The .git directory contains, among other
1097things, a compressed object database representing the complete history
1098of the project, an "index" file which links that history to the current
1099contents of the working tree, and named pointers into that history such
1100as tags and branch heads.
1101
1102The object database contains objects of three main types: blobs, which
1103hold file data; trees, which point to blobs and other trees to build up
1104directory hierarchies; and commits, which each reference a single tree
1105and some number of parent commits.
1106
1107The commit, equivalent to what other systems call a "changeset" or
1108"version", represents a step in the project's history, and each parent
1109represents an immediately preceding step. Commits with more than one
1110parent represent merges of independent lines of development.
1111
1112All objects are named by the SHA-1 hash of their contents, normally
1113written as a string of 40 hex digits. Such names are globally unique.
1114The entire history leading up to a commit can be vouched for by signing
1115just that commit. A fourth object type, the tag, is provided for this
1116purpose.
1117
1118When first created, objects are stored in individual files, but for
1119efficiency may later be compressed together into "pack files".
1120
1121Named pointers called refs mark interesting points in history. A ref
1122may contain the SHA-1 name of an object or the name of another ref (the
1123latter is called a "symbolic ref").
1124Refs with names beginning `refs/head/` contain the SHA-1 name of the most
1125recent commit (or "head") of a branch under development. SHA-1 names of
1126tags of interest are stored under `refs/tags/`. A symbolic ref named
1127`HEAD` contains the name of the currently checked-out branch.
1128
1129The index file is initialized with a list of all paths and, for each
1130path, a blob object and a set of attributes. The blob object represents
1131the contents of the file as of the head of the current branch. The
1132attributes (last modified time, size, etc.) are taken from the
1133corresponding file in the working tree. Subsequent changes to the
1134working tree can be found by comparing these attributes. The index may
1135be updated with new content, and new commits may be created from the
1136content stored in the index.
1137
1138The index is also capable of storing multiple entries (called "stages")
1139for a given pathname. These stages are used to hold the various
1140unmerged version of a file when a merge is in progress.
1141
1142SECURITY
1143--------
1144
1145Some configuration options and hook files may cause Git to run arbitrary
1146shell commands. Because configuration and hooks are not copied using
1147`git clone`, it is generally safe to clone remote repositories with
1148untrusted content, inspect them with `git log`, and so on.
1149
1150However, it is not safe to run Git commands in a `.git` directory (or
1151the working tree that surrounds it) when that `.git` directory itself
1152comes from an untrusted source. The commands in its config and hooks
1153are executed in the usual way.
1154
1155By default, Git will refuse to run when the repository is owned by
1156someone other than the user running the command. See the entry for
1157`safe.directory` in linkgit:git-config[1]. While this can help protect
1158you in a multi-user environment, note that you can also acquire
1159untrusted repositories that are owned by you (for example, if you
1160extract a zip file or tarball from an untrusted source). In such cases,
1161you'd need to "sanitize" the untrusted repository first.
1162
1163If you have an untrusted `.git` directory, you should first clone it
1164with `git clone --no-local` to obtain a clean copy. Git does restrict
1165the set of options and hooks that will be run by `upload-pack`, which
1166handles the server side of a clone or fetch, but beware that the
1167surface area for attack against `upload-pack` is large, so this does
1168carry some risk. The safest thing is to serve the repository as an
1169unprivileged user (either via linkgit:git-daemon[1], ssh, or using
1170other tools to change user ids). See the discussion in the `SECURITY`
1171section of linkgit:git-upload-pack[1].
1172
1173FURTHER DOCUMENTATION
1174---------------------
1175
1176See the references in the "description" section to get started
1177using Git. The following is probably more detail than necessary
1178for a first-time user.
1179
1180The link:user-manual.html#git-concepts[Git concepts chapter of the
1181user-manual] and linkgit:gitcore-tutorial[7] both provide
1182introductions to the underlying Git architecture.
1183
1184See linkgit:gitworkflows[7] for an overview of recommended workflows.
1185
1186See also the link:howto-index.html[howto] documents for some useful
1187examples.
1188
1189The internals are documented in the
1190link:technical/api-index.html[Git API documentation].
1191
1192Users migrating from CVS may also want to
1193read linkgit:gitcvs-migration[7].
1194
1195
1196Authors
1197-------
1198Git was started by Linus Torvalds, and is currently maintained by Junio
1199C Hamano. Numerous contributions have come from the Git mailing list
1200<git@vger.kernel.org>. https://openhub.net/p/git/contributors/summary
1201gives you a more complete list of contributors.
1202
1203If you have a clone of git.git itself, the
1204output of linkgit:git-shortlog[1] and linkgit:git-blame[1] can show you
1205the authors for specific parts of the project.
1206
1207Reporting Bugs
1208--------------
1209
1210Report bugs to the Git mailing list <git@vger.kernel.org> where the
1211development and maintenance is primarily done. You do not have to be
1212subscribed to the list to send a message there. See the list archive
1213at https://lore.kernel.org/git for previous bug reports and other
1214discussions.
1215
1216Issues which are security relevant should be disclosed privately to
1217the Git Security mailing list <git-security@googlegroups.com>.
1218
1219SEE ALSO
1220--------
1221linkgit:gittutorial[7],
1222linkgit:giteveryday[7], linkgit:gitcvs-migration[7],
1223linkgit:gitglossary[7], linkgit:gitdatamodel[7],
1224linkgit:gitcore-tutorial[7], linkgit:gitcli[7],
1225link:user-manual.html[The Git User's Manual],
1226linkgit:gitworkflows[7]
1227
1228GIT
1229---
1230Part of the linkgit:git[1] suite