GIT(1)

๐Ÿ’… GIT(1) ๐Ÿ’…

Git Manual energy, bestie โ€” we're literally in it. This page is GIT(1), and it's about to explain the whole vibe.


๐ŸŽ€ NAME ๐ŸŽ€

git โ€” the stupid content tracker ๐Ÿ’€


โœจ SYNOPSIS โœจ

git [-v | --version] [-h | --help] [-C <path>] [-c <name>=<value>]
    [--exec-path[=<path>]] [--html-path] [--man-path] [--info-path]
    [-p | --paginate | -P | --no-pager] [--no-replace-objects] [--no-lazy-fetch]
    [--no-optional-locks] [--no-advice] [--bare] [--git-dir=<path>]
    [--work-tree=<path>] [--namespace=<name>] [--config-env=<name>=<envvar>]
    <command> [<args>]

๐Ÿฆ‹ DESCRIPTION ๐Ÿฆ‹

Okay so Git is a fast, scalable, distributed revision control system with an unusually rich command set that provides both high-level operations and full access to internals. It's giving powerhouse, honestly.

See gittutorial(7) to get started, then see giteveryday(7) for a useful minimum set of commands. The Git Userโ€™s Manual[1] has a more in-depth introduction. See gitdatamodel(7) if you want to learn about the data model and important terminology. iykyk โ€” the data model is lowkey the main character.

After you mastered the basic concepts, you can come back to this page to learn what commands Git offers. You can learn more about individual Git commands with git help command. gitcli(7) manual page gives you an overview of the command-line command syntax. Slay.

A formatted and hyperlinked copy of the latest Git documentation can be viewed at https://git.github.io/htmldocs/git.html or https://git-scm.com/docs. Bookmark it, bestie ๐Ÿซถ


๐Ÿ’… OPTIONS ๐Ÿ’…

  • -v, --version โ€” Prints the Git suite version that the git program came from. ๐Ÿท๏ธ

This option is internally converted to git version ... and accepts the same options as the git-version(1) command. If --help is also given, it takes precedence over --version. Not me getting overruled by help ๐Ÿ˜ญ

  • -h, --help โ€” Prints the synopsis and a list of the most commonly used commands. If the option --all or -a is given then all available commands are printed. If a Git command is named this option will bring up the manual page for that command. ๐Ÿซถ

Other options are available to control how the manual page is displayed. See git-help(1) for more information, because git --help ... is converted internally into git help ....

  • -C <path> โ€” Run as if git was started in <path> instead of the current working directory. When multiple -C options are given, each subsequent non-absolute -C <path> is interpreted relative to the preceding -C <path>. If <path> is present but empty, e.g. -C "", then the current working directory is left unchanged. ๐ŸŒ€

This option affects options that expect path name like --git-dir and --work-tree in that their interpretations of the path names would be made relative to the working directory caused by the -C option. For example the following invocations are equivalent:

git --git-dir=a.git --work-tree=b -C c status
git --git-dir=c/a.git --work-tree=c/b status
  • -c <name>=<value> โ€” Pass a configuration parameter to the command. The value given will override values from configuration files. The <name> is expected in the same format as listed by git config (subkeys separated by dots). โš™๏ธ

Note that omitting the = in git -c foo.bar ... is allowed and sets foo.bar to the boolean true value (just like [foo]bar would in a config file). Including the equals but with an empty value (like git -c foo.bar= ...) sets foo.bar to the empty string which git config --type=bool will convert to false. The way that's so specific ๐Ÿ˜ญ

  • --config-env=<name>=<envvar> โ€” Like -c <name>=<value>, give configuration variable <name> a value, where <envvar> is the name of an environment variable from which to retrieve the value. Unlike -c there is no shortcut for directly setting the value to an empty string, instead the environment variable itself must be set to the empty string. It is an error if the <envvar> does not exist in the environment. <envvar> may not contain an equals sign to avoid ambiguity with <name> containing one. ๐Ÿ”

This is useful for cases where you want to pass transitory configuration options to git, but are doing so on operating systems where other processes might be able to read your command line (e.g. /proc/self/cmdline), but not your environment (e.g. /proc/self/environ). That behavior is the default on Linux, but may not be on your system.

Note that this might add security for variables such as http.extraHeader where the sensitive information is part of the value, but not e.g. url.<base>.insteadOf where the sensitive information can be part of the key. Important distinction, bestie ๐Ÿ’…

  • --exec-path[=<path>] โ€” Path to wherever your core Git programs are installed. This can also be controlled by setting the GIT_EXEC_PATH environment variable. If no path is given, git will print the current setting and then exit. ๐Ÿ“
  • --html-path โ€” Print the path, without trailing slash, where Gitโ€™s HTML documentation is installed and exit. ๐ŸŒ
  • --man-path โ€” Print the manpath (see man(1)) for the man pages for this version of Git and exit. ๐Ÿ“–
  • --info-path โ€” Print the path where the Info files documenting this version of Git are installed and exit. ๐Ÿ—‚๏ธ
  • -p, --paginate โ€” Pipe all output into less (or if set, $PAGER) if standard output is a terminal. This overrides the pager.<cmd> configuration options (see the "Configuration Mechanism" section below). ๐Ÿ“œ
  • -P, --no-pager โ€” Do not pipe Git output into a pager. No scrolling era, periodt.
  • --git-dir=<path> โ€” Set the path to the repository (".git" directory). This can also be controlled by setting the GIT_DIR environment variable. It can be an absolute path or relative path to current working directory. ๐Ÿ“‚

Specifying the location of the ".git" directory using this option (or GIT_DIR environment variable) turns off the repository discovery that tries to find a directory with ".git" subdirectory (which is how the repository and the top-level of the working tree are discovered), and tells Git that you are at the top level of the working tree. If you are not at the top-level directory of the working tree, you should tell Git where the top-level of the working tree is, with the --work-tree=<path> option (or GIT_WORK_TREE environment variable) ๐Ÿซ 

If you just want to run git as if it was started in <path> then use git -C <path>. That's the shortcut, bestie โœจ

  • --work-tree=<path> โ€” Set the path to the working tree. It can be an absolute path or a path relative to the current working directory. This can also be controlled by setting the GIT_WORK_TREE environment variable and the core.worktree configuration variable (see core.worktree in git-config(1) for a more detailed discussion). ๐ŸŒณ
  • --namespace=<path> โ€” Set the Git namespace. See gitnamespaces(7) for more details. Equivalent to setting the GIT_NAMESPACE environment variable. ๐Ÿช
  • --bare โ€” Treat the repository as a bare repository. If GIT_DIR environment is not set, it is set to the current working directory. ๐Ÿงบ
  • --no-replace-objects โ€” Do not use replacement refs to replace Git objects. This is equivalent to exporting the GIT_NO_REPLACE_OBJECTS environment variable with any value. See git-replace(1) for more information. ๐Ÿšซ
  • --no-lazy-fetch โ€” Do not fetch missing objects from the promisor remote on demand. Useful together with git cat-file -e <object> to see if the object is locally available. This is equivalent to setting the GIT_NO_LAZY_FETCH environment variable to 1. ๐Ÿ’ค
  • --no-optional-locks โ€” Do not perform optional operations that require locks. This is equivalent to setting the GIT_OPTIONAL_LOCKS to 0. ๐Ÿ”’
  • --no-advice โ€” Disable all advice hints from being printed. Silence era ๐Ÿ™ˆ
  • --literal-pathspecs โ€” Treat pathspecs literally (i.e. no globbing, no pathspec magic). This is equivalent to setting the GIT_LITERAL_PATHSPECS environment variable to 1. ๐Ÿ”ค
  • --glob-pathspecs โ€” Add "glob" magic to all pathspec. This is equivalent to setting the GIT_GLOB_PATHSPECS environment variable to 1. Disabling globbing on individual pathspecs can be done using pathspec magic ":(literal)". ๐ŸŒˆ
  • --noglob-pathspecs โ€” Add "literal" magic to all pathspec. This is equivalent to setting the GIT_NOGLOB_PATHSPECS environment variable to 1. Enabling globbing on individual pathspecs can be done using pathspec magic ":(glob)". ๐Ÿงš
  • --icase-pathspecs โ€” Add "icase" magic to all pathspec. This is equivalent to setting the GIT_ICASE_PATHSPECS environment variable to 1. ๐Ÿ” 
  • --list-cmds=<group>[,<group>...] โ€” List commands by group. This is an internal/experimental option and may change or be removed in the future. Supported groups are: builtins, parseopt (builtin commands that use parse-options), deprecated (deprecated builtins), main (all commands in libexec directory), others (all other commands in $PATH that have git-prefix), list-<category> (see categories in command-list.txt), nohelpers (exclude helper commands), alias and config (retrieve command list from config variable completion.commands). ๐Ÿงช
  • --attr-source=<tree-ish> โ€” Read gitattributes from <tree-ish> instead of the worktree. See gitattributes(5). This is equivalent to setting the GIT_ATTR_SOURCE environment variable. ๐ŸŒธ

๐ŸŒˆ GIT COMMANDS ๐ŸŒˆ

We divide Git into high level ("porcelain") commands and low level ("plumbing") commands. Yes bestie, porcelain and plumbing โ€” iconic naming, no notes.

For defining command aliases, see git-config(1) and look for descriptions of alias.*. For installing custom "git" subcommands, see the description for the PATH environment variable in this manual. ๐Ÿ‘‘

โœจ HIGH-LEVEL COMMANDS (PORCELAIN) โœจ

Okay so the porcelain commands are the ones you actually touch day to day, and Git splits them into the main girlies ๐ŸŽ€ and a bunch of ancillary little helper utilities that do the side-quests. Let's get into it bestie, no cap.


๐ŸŒธ Main porcelain commands ๐ŸŒธ

These are the icons. The main characters. The ones you'll type a thousand times before you graduate:

  • git-add(1) โ€” Add file contents to the index. (aka "babe, this goes in the staging area now")
  • git-am(1) โ€” Apply a series of patches from a mailbox.
  • git-archive(1) โ€” Create an archive of files from a named tree.
  • git-backfill(1) โ€” Download missing objects in a partial clone.
  • git-bisect(1) โ€” Use binary search to find the commit that introduced a bug. Detective mode fr ๐Ÿ”
  • git-branch(1) โ€” List, create, or delete branches.
  • git-bundle(1) โ€” Move objects and refs by archive.
  • git-checkout(1) โ€” Switch branches or restore working tree files.
  • git-cherry-pick(1) โ€” Apply the changes introduced by some existing commits. (stealing a commit but make it legal ๐Ÿ’)
  • git-citool(1) โ€” Graphical alternative to git-commit.
  • git-clean(1) โ€” Remove untracked files from the working tree. (be careful, she's ruthless ๐Ÿ’€)
  • git-clone(1) โ€” Clone a repository into a new directory.
  • git-commit(1) โ€” Record changes to the repository. The moment of truth โœจ
  • git-describe(1) โ€” Give an object a human readable name based on an available ref.
  • git-diff(1) โ€” Show changes between commits, commit and working tree, etc.
  • git-fetch(1) โ€” Download objects and refs from another repository.
  • git-format-patch(1) โ€” Prepare patches for e-mail submission.
  • git-gc(1) โ€” Cleanup unnecessary files and optimize the local repository.
  • git-grep(1) โ€” Print lines matching a pattern.
  • git-gui(1) โ€” A portable graphical interface to Git.
  • git-history(1) โ€” EXPERIMENTAL: Rewrite history. (yes it's giving time traveller, mind the EXPERIMENTAL label bestie ๐Ÿ™ˆ)
  • git-init(1) โ€” Create an empty Git repository or reinitialize an existing one.
  • git-log(1) โ€” Show commit logs.
  • git-maintenance(1) โ€” Run tasks to optimize Git repository data.
  • git-merge(1) โ€” Join two or more development histories together.
  • git-mv(1) โ€” Move or rename a file, a directory, or a symlink.
  • git-notes(1) โ€” Add or inspect object notes.
  • git-pull(1) โ€” Fetch from and integrate with another repository or a local branch.
  • git-push(1) โ€” Update remote refs along with associated objects. The scary one, we respect her ๐Ÿซถ
  • git-range-diff(1) โ€” Compare two commit ranges (e.g. two versions of a branch).
  • git-rebase(1) โ€” Reapply commits on top of another base tip.
  • git-reset(1) โ€” Set HEAD or the index to a known state.
  • git-restore(1) โ€” Restore working tree files.
  • git-revert(1) โ€” Revert some existing commits.
  • git-rm(1) โ€” Remove files from the working tree and from the index.
  • git-shortlog(1) โ€” Summarize git log output.
  • git-show(1) โ€” Show various types of objects.
  • git-sparse-checkout(1) โ€” Reduce your working tree to a subset of tracked files.
  • git-stash(1) โ€” Stash the changes in a dirty working directory away. (the "not right now, later" button ๐Ÿ’…)
  • git-status(1) โ€” Show the working tree status.
  • git-submodule(1) โ€” Initialize, update or inspect submodules.
  • git-switch(1) โ€” Switch branches.
  • git-tag(1) โ€” Create, list, delete or verify tags.
  • git-worktree(1) โ€” Manage multiple working trees.
  • gitk(1) โ€” The Git repository browser.
  • scalar(1) โ€” A tool for managing large Git repositories.

๐ŸŽ€ Ancillary Commands ๐ŸŽ€

The supporting cast. Not the leads, but the plot does not work without them, periodt.

Manipulators:

These ones change stuff. Handle with care bestie, they can rearrange your whole life:

Interrogators:

And these ones just ask questions. Nosy but harmless, we love an information-gathering queen ๐Ÿ”:

  • git-annotate(1) โ€” Annotate file lines with commit information.
  • git-blame(1) โ€” Show what revision and author last modified each line of a file. (snitching on your teammates since forever ๐Ÿ’€)
  • git-bugreport(1) โ€” Collect information for user to file a bug report.
  • git-count-objects(1) โ€” Count unpacked number of objects and their disk consumption.
  • git-diagnose(1) โ€” Generate a zip archive of diagnostic information.
  • git-difftool(1) โ€” Show changes using common diff tools.
  • git-fsck(1) โ€” Verifies the connectivity and validity of the objects in the database.
  • git-help(1) โ€” Display help information about Git.
  • git-instaweb(1) โ€” Instantly browse your working repository in gitweb.
  • git-merge-tree(1) โ€” Perform merge without touching index or working tree. (merge, but make it โœจghostโœจ)
  • git-rerere(1) โ€” Reuse recorded resolution of conflicted merges.
  • git-show-branch(1) โ€” Show branches and their commits.
  • git-verify-commit(1) โ€” Check the GPG signature of commits.
  • git-verify-tag(1) โ€” Check the GPG signature of tags.
  • git-version(1) โ€” Display version information about Git.
  • git-whatchanged(1) โ€” Show logs with differences each commit introduces.
  • gitweb(1) โ€” Git web interface (web frontend to Git repositories).

๐Ÿฆ‹ Interacting with Others ๐Ÿฆ‹

This little crew is all about talking to foreign SCMs and to other humans via patches over e-mail. Networking, but nerdy and honestly kind of iconic:

  • git-archimport(1) โ€” Import a GNU Arch repository into Git.
  • git-cvsexportcommit(1) โ€” Export a single commit to a CVS checkout.
  • git-cvsimport(1) โ€” Salvage your data out of another SCM people love to hate. (yes that's the actual description, no I did not write it, but I felt it ๐Ÿ’€)
  • git-cvsserver(1) โ€” A CVS server emulator for Git.
  • git-imap-send(1) โ€” Send a collection of patches from stdin to an IMAP folder.
  • git-p4(1) โ€” Import from and submit to Perforce repositories.
  • git-quiltimport(1) โ€” Applies a quilt patchset onto the current branch.
  • git-request-pull(1) โ€” Generates a summary of pending changes.
  • git-send-email(1) โ€” Send a collection of patches as emails.
  • git-svn(1) โ€” Bidirectional operation between a Subversion repository and Git.

๐Ÿ’œ Reset, restore and revert ๐Ÿ’œ

Okay this is the part where everybody gets confused, so listen up bestie, because there are three commands with lowkey similar names and they are not the same thing:

  • git-revert(1) is about making a new commit that reverts the changes made by other commits.
  • git-restore(1) is about restoring files in the working tree from either the index or another commit. This command does not update your branch. The command can also be used to restore files in the index from another commit.
  • git-reset(1) is about updating your branch, moving the tip in order to add or remove commits from the branch. This operation changes the commit history.
git reset can also be used to restore the index, overlapping with git restore. ๐Ÿ™ˆ

So like: revert = new commit that undoes, restore = files only, no branch drama, reset = moves your branch tip and rewrites history. Different girls, different jobs ๐Ÿ’…โœจ

๐Ÿ”ง LOW-LEVEL COMMANDS (PLUMBING) ๐Ÿ”ง

okay so likeโ€ฆ Git ships with its own porcelain layer, right? but the low-level commands are literally enough on their own to build whole alternative porcelains with bestie. if you're the kind of dev who wants to do that, start by reading git-update-index(1) and git-read-tree(1) โ€” that's the doorway ๐Ÿ’…

and here's the tea: the interface to these low-level commands (input, output, set of options, the whole semantics situation) is meant to be way more stable than the Porcelain-level ones, because plumbing commands are primarily for scripted use. Porcelain interfaces? those are subject to change so the end-user experience can keep getting better. different vibes, different rules โœจ

the low-level commands split into three little groups: ones that manipulate objects (in the repository, index, and working tree), ones that interrogate and compare objects, and ones that move objects and references between repositories. so organized, honestly ๐Ÿซถ

๐Ÿ› ๏ธ Manipulation commands

๐Ÿ” Interrogation commands

big mood: in general, the interrogate commands do not touch the files in the working tree. they just look. no cap, they're literally just observing ๐Ÿ‘€โœจ

๐Ÿ”„ Syncing repositories

the following are helper commands used by the ones above โ€” end users typically do not use them directly, so likeโ€ฆ no pressure bestie ๐Ÿ™ˆ

๐Ÿงฐ Internal helper commands

these are internal helper commands used by other commands; end users typically do not use them directly either, so consider this the backstage pass ๐ŸŽŸ๏ธ


๐Ÿ“– GUIDES ๐Ÿ“–

these are the documentation pages that actually explain Git concepts, like the lore of it all ๐Ÿงš


๐Ÿ—‚๏ธ REPOSITORY, COMMAND AND FILE INTERFACES ๐Ÿ—‚๏ธ

this documentation discusses repository and command interfaces which users are expected to interact with directly. see --user-formats in git-help(1) for more details on the criteria, iykyk ๐Ÿ’…

  • gitattributes(5) โ€” defining attributes per path. ๐Ÿท๏ธ
  • gitcli(7) โ€” Git command-line interface and conventions. โŒจ๏ธ
  • githooks(5) โ€” hooks used by Git. ๐Ÿช
  • gitignore(5) โ€” specifies intentionally untracked files to ignore. ๐Ÿ™ˆ
  • gitmailmap(5) โ€” map author/committer names and/or E-Mail addresses. ๐Ÿ“ง
  • gitmodules(5) โ€” defining submodule properties. ๐Ÿงฉ
  • gitrepository-layout(5) โ€” Git Repository Layout. ๐Ÿ—๏ธ
  • gitrevisions(7) โ€” specifying revisions and ranges for Git. ๐Ÿ”ข

๐Ÿงฌ FILE FORMATS, PROTOCOLS AND OTHER DEVELOPER INTERFACES ๐Ÿงฌ

this documentation discusses file formats, over-the-wire protocols and other git developer interfaces. see --developer-interfaces in git-help(1) โ€” yes, that's where the criteria live ๐Ÿซถ


โš™๏ธ CONFIGURATION MECHANISM โš™๏ธ

okay so Git uses a simple text format to store customizations that are per repository and per user. the config file can literally look like this:

#
# A '#' or ';' character indicates a comment.
#

; core variables
[core]
        ; Don't trust file modes
        filemode = false

; user identity
[user]
        name = "Junio C Hamano"
        email = "gitster@pobox.com"

various commands read from the configuration file and adjust their operation accordingly. see git-config(1) for a list and more details about the configuration mechanism โ€” that's the whole master doc for config behavior, highly recommend ๐Ÿซถโœจ

๐Ÿท๏ธ IDENTIFIER TERMINOLOGY

Okay so before anything else, let's get the vocab down, because Git docs throw these angle-bracket words around constantly and if you don't know them you're gonna be lost the whole time. ๐Ÿ’…

  • <object> โ€” the object name for any type of object. The general-purpose one.
  • <blob> โ€” a blob object name. Just the file-content bits, no name, no perms.
  • <tree> โ€” a tree object name. Directory vibes.
  • <commit> โ€” a commit object name. The whole snapshot moment, icon behavior.
  • <tree-ish> โ€” a tree, commit, or tag object name. Lowkey the important bit: a command that takes a <tree-ish> argument ultimately wants to operate on a <tree> object, but it'll automatically dereference <commit> and <tag> objects that point at a <tree>. So it's flexible, it'll do the homework for you โœจ
  • <commit-ish> โ€” a commit or tag object name. Same deal: a command taking a <commit-ish> argument ultimately wants to operate on a <commit> object, but automatically dereferences <tag> objects that point at a <commit>.
  • <type> โ€” means an object type is required. Currently one of: blob, tree, commit, or tag. Just those four, no cap.
  • <file> โ€” a filename โ€” and this is the sneaky part โ€” almost always relative to the root of the tree structure GIT_INDEX_FILE describes. Not your cwd, bestie. The root of that tree. ๐Ÿซถ

๐Ÿ”ฎ SYMBOLIC IDENTIFIERS

Any Git command that accepts any <object> can also use these symbolic shortcuts, and they're so convenient:

  • HEAD โ€” indicates the head of the current branch. The main character, literally.
  • <tag> โ€” a valid tag name (i.e. a refs/tags/<tag> reference).
  • <head> โ€” a valid head name (i.e. a refs/heads/<head> reference).

For the full, complete, exhaustive list of ways you can spell object names, go read the "SPECIFYING REVISIONS" section in gitrevisions(7). There are so many ways. It's giving encyclopedia. ๐Ÿ“š


๐Ÿ—‚๏ธ FILE/DIRECTORY STRUCTURE

Please see the gitrepository-layout(5) document for how the guts are laid out. ๐Ÿ’–

Read githooks(5) for more details about each hook โ€” yes, each one has its own whole personality.

Higher level SCMs may provide and manage additional information in the $GIT_DIR. So if you're using something sitting on top of Git, it can stash its own stuff in there too.


๐Ÿ“– TERMINOLOGY

Please see gitglossary(7) โ€” that's the dictionary, go nuts.

And see gitdatamodel(7) for a discussion of the core data model, which includes important terminology used throughout the documentation. Genuinely worth the read if you want the whole thing to click. ๐Ÿง โœจ


๐ŸŒฑ ENVIRONMENT VARIABLES

Various Git commands pay attention to environment variables and change their behavior accordingly โ€” they're like little mood rings for your shell, but make it functional. ๐Ÿ’…

Quick note on the ones marked "Boolean": they take their values the same way as Boolean valued configuration variables. So "true", "yes", "on" and positive numbers are all taken as "yes", while "false", "no", "off", and "0" are taken as "no". Easy.

Here are the variables, bestie:

๐Ÿ–ฅ๏ธ System

  • HOME โ€” specifies the path to the user's home directory. On Windows, if it's unset, Git will set a process environment variable equal to: $HOMEDRIVE$HOMEPATH if both $HOMEDRIVE and $HOMEPATH exist; otherwise $USERPROFILE if $USERPROFILE exists. Windows really said "why have one variable when three will do" ๐Ÿ˜ญ
  • PATH โ€” when a user runs git <command> that is not part of the core Git programs (installed in GIT_EXEC_PATH), git-<command> that is runnable by the user in a directory on $PATH is invoked. Arguments passed after the command name are passed as-is to the program. And here's the ordering tea: to execute git <foo>, git finds command <foo> (either a core Git program found in GIT_EXEC_PATH, or a custom one in a directory on PATH), before trying foo as an alias. So real programs win over aliases. Periodt. ๐Ÿ‘‘

๐Ÿ“ฆ The Git Repository

These environment variables apply to all core Git commands. But โ€” important caveat โ€” it's worth noting that they may be used/overridden by SCMs sitting above Git, so take care if you're using a foreign front-end. ๐Ÿ‘€

  • GIT_INDEX_FILE โ€” specifies an alternate index file. If not specified, the default of $GIT_DIR/index is used.
  • GIT_INDEX_VERSION โ€” specifies what index version is used when writing the index file out. It won't affect existing index files. By default index file version 2 or 3 is used. See git-update-index(1) for more information.
  • GIT_OBJECT_DIRECTORY โ€” if the object storage directory is specified via this environment variable, then the sha1 directories are created underneath it โ€” otherwise the default $GIT_DIR/objects directory is used.
  • GIT_ALTERNATE_OBJECT_DIRECTORIES โ€” okay so this is a good one. Because Git objects are immutable, old objects can be archived into shared, read-only directories. This variable specifies a ":" separated (on Windows ";" separated) list of Git object directories which can be used to search for Git objects. New objects will not be written to these directories. Read-only means read-only, bestie. ๐Ÿ™…โ€โ™€๏ธ

Entries that begin with " (double-quote) will be interpreted as C-style quoted paths, removing leading and trailing double-quotes and respecting backslash escapes. E.g., the value "path-with-\"-and-:-in-it":vanilla-path has two paths: path-with-"-and-:-in-it and vanilla-path. Cute little escape hatch for when your path is full of chaos. ๐ŸŒ€

  • GIT_DIR โ€” if this is set, it specifies a path to use instead of the default .git for the base of the repository. The --git-dir command-line option also sets this value.
  • GIT_WORK_TREE โ€” set the path to the root of the working tree. This can also be controlled by the --work-tree command-line option and the core.worktree configuration variable. Three ways to say the same thing, slay.
  • GIT_NAMESPACE โ€” set the Git namespace; see gitnamespaces(7) for details. The --namespace command-line option also sets this value.
  • GIT_CEILING_DIRECTORIES โ€” this should be a colon-separated list of absolute paths. If set, it's a list of directories that Git should not chdir up into while looking for a repository directory. Super useful for excluding slow-loading network directories. ๐ŸŒ

Important details: it will not exclude the current working directory, or a GIT_DIR set on the command line or in the environment. Normally, Git has to read the entries in this list and resolve any symlink that might be present in order to compare them with the current directory. But โ€” if even this access is slow, you can add an empty entry to the list to tell Git that the subsequent entries are not symlinks and needn't be resolved; e.g., GIT_CEILING_DIRECTORIES=/maybe/symlink::/very/slow/non/symlink. That double colon is doing so much work. ๐Ÿ’€

  • GIT_DISCOVERY_ACROSS_FILESYSTEM โ€” when run in a directory that does not have a .git repository directory, Git tries to find such a directory in the parent directories to find the top of the working tree โ€” but by default it does not cross filesystem boundaries. This Boolean environment variable can be set to true to tell Git not to stop at filesystem boundaries. Like GIT_CEILING_DIRECTORIES, this will not affect an explicit repository directory set via GIT_DIR or on the command line.
  • GIT_COMMON_DIR โ€” if this variable is set to a path, non-worktree files that are normally in $GIT_DIR will be taken from this path instead. Worktree-specific files such as HEAD or index are taken from $GIT_DIR. See gitrepository-layout(5) and git-worktree(1) for details. Note: this variable has lower precedence than other path variables such as GIT_INDEX_FILE, GIT_OBJECT_DIRECTORYโ€ฆ so it's not the boss of those, no matter how it acts. ๐Ÿ™ˆ
  • GIT_DEFAULT_HASH โ€” if this variable is set, the default hash algorithm for new repositories will be set to this value. This value is ignored when cloning โ€” the setting of the remote repository is always used instead. The default is "sha1". See --object-format in git-init(1).
  • GIT_DEFAULT_REF_FORMAT โ€” if this variable is set, the default reference backend format for new repositories will be set to this value. The default is "files". See --ref-format in git-init(1).
  • GIT_REFERENCE_BACKEND โ€” specify which reference backend to be used along with its URI. See the extensions.refStorage option in git-config(1) for more details. Overrides the config variable when used. Yeah, it wins. ๐Ÿ’ช

โœ๏ธ Git Commits

  • GIT_AUTHOR_NAME โ€” the human-readable name used in the author identity when creating commit or tag objects, or when writing reflogs. Overrides the user.name and author.name configuration settings.
  • GIT_AUTHOR_EMAIL โ€” the email address used in the author identity when creating commit or tag objects, or when writing reflogs. Overrides the user.email and author.email configuration settings.
  • GIT_AUTHOR_DATE โ€” the date used for the author identity when creating commit or tag objects, or when writing reflogs. See git-commit(1) for valid formats. There are lots of valid formats. Go wild, respectfully. ๐Ÿ“…
  • GIT_COMMITTER_NAME โ€” the human-readable name used in the committer identity when creating commit or tag objects, or when writing reflogs. Overrides the user.name and committer.name configuration settings.
  • GIT_COMMITTER_EMAIL โ€” the email address used in the author identity when creating commit or tag objects, or when writing reflogs. Overrides the user.email and committer.email configuration settings.
  • GIT_COMMITTER_DATE โ€” the date used for the committer identity when creating commit or tag objects, or when writing reflogs. See git-commit(1) for valid formats.
  • EMAIL โ€” the email address used in the author and committer identities if no other relevant environment variable or configuration setting has been set. The final fallback bestie, the last one standing. ๐Ÿซถ

๐Ÿ”€ Git Diffs

  • GIT_DIFF_OPTS โ€” the only valid setting is "--unified=??" or "-u??" to set the number of context lines shown when a unified diff is created. This takes precedence over any "-U" or "--unified" option value passed on the Git diff command line. So it overrules your flags, lowkey rude but iconic.
  • GIT_EXTERNAL_DIFF โ€” when this environment variable is set, the program named by it is called to generate diffs, and Git does not use its builtin diff machinery. Plug in your own diff engine, main character energy. ๐Ÿ”ฅ

For a path that is added, removed, or modified, GIT_EXTERNAL_DIFF is called with 7 parameters:

path old-file old-hex old-mode new-file new-hex new-mode

where:

  • <old|new>-file โ€” are files GIT_EXTERNAL_DIFF can use to read the contents of <old|new>,
  • <old|new>-hex โ€” are the 40-hexdigit SHA-1 hashes,
  • <old|new>-mode โ€” are the octal representation of the file modes.

The file parameters can point at the user's working file (e.g. new-file in git-diff-files), /dev/null (e.g. old-file when a new file is added), or a temporary file (e.g. old-file in the index). And heads up: GIT_EXTERNAL_DIFF should not worry about unlinking the temporary file โ€” it is removed when GIT_EXTERNAL_DIFF exits. Git handles the cleanup, you just vibe. โœจ

For a path that is unmerged, GIT_EXTERNAL_DIFF is called with 1 parameter, <path>.

For each path GIT_EXTERNAL_DIFF is called on, two environment variables โ€” GIT_DIFF_PATH_COUNTER and GIT_DIFF_PATH_TOTAL โ€” are set.

  • GIT_EXTERNAL_DIFF_TRUST_EXIT_CODE โ€” if this Boolean environment variable is set to true, then the GIT_EXTERNAL_DIFF command is expected to return exit code 0 if it considers the input files to be equal, or 1 if it considers them to be different, like diff(1). If it is set to false โ€” which is the default โ€” then the command is expected to return exit code 0 regardless of equality. Any other exit code causes Git to report a fatal error ๐Ÿ’€. So yeah, know which mode you're in before you ship that diff driver.
  • GIT_DIFF_PATH_COUNTER โ€” a 1-based counter incremented by one for every path.

โ€ฆand the env var section is still going, stay with me bestie ๐Ÿซถ

  • GIT_DIFF_PATH_TOTAL โ€” the total number of paths. that's it, that's the whole vibe ๐Ÿ’…

๐ŸŒธ other ๐ŸŒธ

  • GIT_MERGE_VERBOSITY โ€” a number controlling how much output the recursive merge strategy shows. it overrides merge.verbosity. see git-merge(1) for the lore โœจ
  • GIT_PAGER โ€” overrides $PAGER. and bestie, listen: if you set it to an empty string or to the value "cat", Git will not launch a pager at all ๐Ÿšซ๐Ÿ“„. see also the core.pager option in git-config(1).
  • GIT_PROGRESS_DELAY โ€” a number controlling how many seconds to delay before showing optional progress indicators. defaults to 1 โณ.
  • GIT_EDITOR โ€” overrides $EDITOR and $VISUAL. several Git commands use it when they need to launch an editor in interactive mode. see also git-var(1) and the core.editor option in git-config(1) ๐Ÿ–Š๏ธ.
  • GIT_SEQUENCE_EDITOR โ€” overrides the configured Git editor specifically when you're editing the todo list of an interactive rebase. see also git-rebase(1) and the sequence.editor option in git-config(1) ๐Ÿ“.
  • GIT_SSH, GIT_SSH_COMMAND โ€” if either one is set, then git fetch and git push will use the specified command instead of ssh when they need to connect to a remote system. the command-line parameters passed to the configured command are determined by the ssh variant โ€” see the ssh.variant option in git-config(1) for the deets.
    • $GIT_SSH_COMMAND takes precedence over $GIT_SSH, and it's interpreted by the shell, which means you can sneak extra arguments in there ๐Ÿš.
    • $GIT_SSH on the other hand must be just the path to a program (which can totally be a wrapper shell script if you need extra arguments โ€” loophole unlocked).
    • usually it's easier to configure whatever options you want through your personal .ssh/config file. please consult your ssh documentation for further details ๐Ÿซถ.
  • GIT_SSH_VARIANT โ€” if this is set, it overrides Git's autodetection of whether GIT_SSH/GIT_SSH_COMMAND/core.sshCommand refer to OpenSSH, plink or tortoiseplink. this variable overrides the config setting ssh.variant, which does the same job ๐Ÿ”.
  • GIT_SSL_NO_VERIFY โ€” setting and exporting this to any value tells Git not to verify the SSL certificate when fetching or pushing over HTTPS.
โš ๏ธ bestie this is the "skip the vibe check" button for certificates. any value. even 0. be so serious about when you use it.
  • GIT_ATTR_SOURCE โ€” sets the treeish that gitattributes will be read from ๐ŸŒณ.
  • GIT_ASKPASS โ€” if this is set, then Git commands that need to acquire passwords or passphrases (e.g. for HTTP or IMAP authentication) will call this program with a suitable prompt as a command-line argument and read the password from its STDOUT. see also the core.askPass option in git-config(1) ๐Ÿ”.
  • GIT_TERMINAL_PROMPT โ€” if this Boolean environment variable is set to false, git will not prompt on the terminal (e.g., when asking for HTTP authentication) ๐Ÿค.
  • GIT_CONFIG_GLOBAL, GIT_CONFIG_SYSTEM โ€” take the configuration from the given files instead of from global or system-level configuration files. if GIT_CONFIG_SYSTEM is set, the system config file defined at build time (usually /etc/gitconfig) will not be read. likewise, if GIT_CONFIG_GLOBAL is set, neither $HOME/.gitconfig nor $XDG_CONFIG_HOME/git/config will be read. can be set to /dev/null to skip reading configuration files of the respective level ๐Ÿ•ณ๏ธ.
  • GIT_CONFIG_NOSYSTEM โ€” whether to skip reading settings from the system-wide $(prefix)/etc/gitconfig file. this Boolean environment variable can be used along with $HOME and $XDG_CONFIG_HOME to create a predictable environment for a picky script, or you can set it to true to temporarily dodge a buggy /etc/gitconfig file while you wait for someone with sufficient permissions to fix it ๐Ÿ› ๏ธ.
  • GIT_FLUSH โ€” if this Boolean environment variable is set to true, then commands such as git blame (in incremental mode), git rev-list, git log, git check-attr and git check-ignore will force a flush of the output stream after each record has been flushed. if it's set to false, the output of these commands will be done using completely buffered I/O. if this environment variable is not set, Git will choose buffered or record-oriented flushing based on whether stdout appears to be redirected to a file or not ๐Ÿšฟ.
  • GIT_TRACE โ€” enables general trace messages, e.g. alias expansion, built-in command execution and external command execution ๐Ÿ‘€.
    • if set to "1", "2" or "true" (comparison is case insensitive), trace messages will be printed to stderr.
    • if it's set to an integer value greater than 2 and lower than 10 (strictly), then Git will interpret this value as an open file descriptor and will try to write the trace messages into that file descriptor.
    • alternatively, if it's set to an absolute path (starting with a / character), Git will interpret this as a file path and will try to append the trace messages to it.
    • unsetting the variable, or setting it to empty, "0" or "false" (case insensitive) disables trace messages ๐Ÿ”‡.
  • GIT_TRACE_FSMONITOR โ€” enables trace messages for the filesystem monitor extension. see GIT_TRACE for available trace output options ๐Ÿ—‚๏ธ.
  • GIT_TRACE_PACK_ACCESS โ€” enables trace messages for all accesses to any packs. for each access, the pack file name and an offset in the pack is recorded. this may be helpful for troubleshooting some pack-related performance problems. see GIT_TRACE for available trace output options ๐Ÿ“ฆ.
  • GIT_TRACE_PACKET โ€” enables trace messages for all packets coming in or out of a given program. this can help with debugging object negotiation or other protocol issues. tracing is turned off at a packet starting with "PACK" (but see GIT_TRACE_PACKFILE below). see GIT_TRACE for available trace output options ๐Ÿ“จ.
  • GIT_TRACE_PACKFILE โ€” enables tracing of packfiles sent or received by a given program. unlike other trace output, this trace is verbatim: no headers, and no quoting of binary data. you almost certainly want to direct it into a file (e.g., GIT_TRACE_PACKFILE=/tmp/my.pack) rather than displaying it on the terminal or mixing it with other trace output ๐Ÿ—ƒ๏ธ.
    • note that this is currently only implemented for the client side of clones and fetches.
  • GIT_TRACE_PERFORMANCE โ€” enables performance related trace messages, e.g. total execution time of each Git command. see GIT_TRACE for available trace output options โฑ๏ธ.
  • GIT_TRACE_REFS โ€” enables trace messages for operations on the ref database. see GIT_TRACE for available trace output options ๐Ÿ”—.
  • GIT_TRACE_SETUP โ€” enables trace messages printing the .git, working tree and current working directory after Git has completed its setup phase. see GIT_TRACE for available trace output options ๐Ÿงญ.
  • GIT_TRACE_SHALLOW โ€” enables trace messages that can help debugging fetching / cloning of shallow repositories. see GIT_TRACE for available trace output options ๐ŸŠ.
  • GIT_TRACE_CURL โ€” enables a curl full trace dump of all incoming and outgoing data, including descriptive information, of the git transport protocol. this is similar to doing curl --trace-ascii on the command line. see GIT_TRACE for available trace output options ๐ŸŒ€.
  • GIT_TRACE_CURL_NO_DATA โ€” when a curl trace is enabled (see GIT_TRACE_CURL above), do not dump data (that is, only dump info lines and headers) ๐Ÿ™ˆ.
  • GIT_TRACE2 โ€” enables more detailed trace messages from the "trace2" library. output from GIT_TRACE2 is a simple text-based format for human readability ๐Ÿ“–.
    • if set to "1", "2" or "true" (comparison is case insensitive), trace messages will be printed to stderr.
    • if it's set to an integer value greater than 2 and lower than 10 (strictly), then Git will interpret this value as an open file descriptor and will try to write the trace messages into that file descriptor.
    • alternatively, if it's set to an absolute path (starting with a / character), Git will interpret this as a file path and will try to append the trace messages to it. if the path already exists and is a directory, the trace messages will be written to files (one per process) in that directory, named according to the last component of the SID and an optional counter (to avoid filename collisions) ๐Ÿ“.
    • in addition, if the variable is set to af_unix:[<socket-type>:]<absolute-pathname>, Git will try to open the path as a Unix Domain Socket. the socket type can be either stream or dgram ๐Ÿ”Œ.
    • unsetting the variable, or setting it to empty, "0" or "false" (case insensitive) disables trace messages.
    • see Trace2 documentation[2] for full details.
  • GIT_TRACE2_EVENT โ€” this setting writes a JSON-based format that is suited for machine interpretation. see GIT_TRACE2 for available trace output options and Trace2 documentation[2] for full details ๐Ÿค–.
  • GIT_TRACE2_PERF โ€” in addition to the text-based messages available in GIT_TRACE2, this setting writes a column-based format for understanding nesting regions. see GIT_TRACE2 for available trace output options and Trace2 documentation[2] for full details ๐Ÿ“Š.
  • GIT_TRACE_REDACT โ€” by default, when tracing is activated, Git redacts the values of cookies, the "Authorization:" header, the "Proxy-Authorization:" header and packfile URIs. set this Boolean environment variable to false to prevent this redaction ๐Ÿ•ต๏ธ.
  • GIT_NO_REPLACE_OBJECTS โ€” setting and exporting this environment variable tells Git to ignore replacement refs and not replace Git objects ๐Ÿšซ๐Ÿ”„.
  • GIT_LITERAL_PATHSPECS โ€” setting this Boolean environment variable to true will cause Git to treat all pathspecs literally, rather than as glob patterns. for example, running GIT_LITERAL_PATHSPECS=1 git log -- '*.c' will search for commits that touch the path *.c, not any paths that the glob *.c matches. you might want this if you're feeding literal paths to Git (e.g., paths previously given to you by git ls-tree, --raw diff output, etc) ๐ŸŽฏ.
  • GIT_GLOB_PATHSPECS โ€” setting this Boolean environment variable to true will cause Git to treat all pathspecs as glob patterns (aka "glob" magic) ๐ŸŒ.
  • GIT_NOGLOB_PATHSPECS โ€” setting this Boolean environment variable to true will cause Git to treat all pathspecs as literal (aka "literal" magic) ๐Ÿ”’.
  • GIT_ICASE_PATHSPECS โ€” setting this Boolean environment variable to true will cause Git to treat all pathspecs as case-insensitive ๐Ÿ” .
  • GIT_NO_LAZY_FETCH โ€” set this Boolean envvar to true and Git will not lazily fetch missing objects from the promisor remote on demand. like, it just won't go get them ๐Ÿ’…
  • GIT_REFLOG_ACTION โ€” whenever a ref gets updated, reflog entries are created to keep track of why the ref was updated (which is usually the name of the high-level command that did the updating), plus the old and new values of the ref. A scripted Porcelain command can use the set_reflog_action helper function in git-sh-setup to set its own name into this variable when the end user invokes it as the top level command, so it gets recorded in the body of the reflog. iykyk ๐ŸŽ€
  • GIT_REF_PARANOIA โ€” if this Boolean envvar is set to false, Git ignores broken or badly named refs when iterating over lists of refs. Normally Git tries to include any such refs, which may cause some operations to fail. And honestly? that's usually preferable, because potentially destructive operations (e.g., git-prune(1)) are way better off aborting than ignoring broken refs (and thus considering the history they point to as not worth saving ๐Ÿ˜ญ). The default value is 1 (i.e., be paranoid about detecting and aborting all operations). You should not normally need to set this to 0, but it may be useful when you're trying to salvage data from a corrupted repository. salvage mission vibes ๐Ÿงš
  • GIT_COMMIT_GRAPH_PARANOIA โ€” when loading a commit object from the commit-graph, Git performs an existence check on the object in the object database. This is done to avoid issues with stale commit-graphs that contain references to already-deleted commits, but it comes with a performance penalty.

The default is "false", which disables the aforementioned behavior. Setting this to "true" enables the existence check so that stale commits will never be returned from the commit-graph โ€” at the cost of performance. pick your battles bestie โš–๏ธ

  • GIT_ALLOW_PROTOCOL โ€” if set to a colon-separated list of protocols, behave as if protocol.allow is set to never, and each of the listed protocols has protocol.<name>.allow set to always (overriding any existing configuration). See the description of protocol.allow in git-config(1) for more details. it's giving allowlist energy ๐Ÿ”ฅ
  • GIT_PROTOCOL_FROM_USER โ€” set this Boolean envvar to false to prevent protocols used by fetch/push/clone which are configured to the user state. This is useful to restrict recursive submodule initialization from an untrusted repository, or for programs which feed potentially-untrusted URLs to git commands. See git-config(1) for more details. protecting the group chat from weird links, we love to see it ๐Ÿซถ
  • GIT_PROTOCOL โ€” for internal use only. Used in handshaking the wire protocol. Contains a colon : separated list of keys with optional values <key>[=<value>]. Presence of unknown keys and values must be ignored.

Note that servers may need to be configured to allow this variable to pass over some transports. It will be propagated automatically when accessing local repositories (i.e., file:// or a filesystem path), as well as over the git:// protocol. For git-over-http, it should work automatically in most configurations, but see the discussion in git-http-backend(1). For git-over-ssh, the ssh server may need to be configured to allow clients to pass this variable (e.g., by using AcceptEnv GIT_PROTOCOL with OpenSSH).

This configuration is optional. If the variable is not propagated, then clients will fall back to the original "v0" protocol (but may miss out on some performance improvements or features). This variable currently only affects clones and fetches; it is not yet used for pushes (but may be in the future). โœจ

  • GIT_OPTIONAL_LOCKS โ€” if this Boolean envvar is set to false, Git will complete any requested operation without performing any optional sub-operations that require taking a lock. For example, this will prevent git status from refreshing the index as a side effect. This is useful for processes running in the background which do not want to cause lock contention with other operations on the repository. Defaults to 1. no drama, no locks ๐Ÿ’…
  • GIT_REDIRECT_STDIN, GIT_REDIRECT_STDOUT, GIT_REDIRECT_STDERR โ€” Windows-only: allow redirecting the standard input/output/error handles to paths specified by the environment variables. This is particularly useful in multi-threaded applications where the canonical way to pass standard handles via CreateProcess() is not an option because it would require the handles to be marked inheritable (and consequently every spawned process would inherit them, possibly blocking regular Git operations). The primary intended use case is to use named pipes for communication (e.g. \\.\pipe\my-git-stdin-123).

Two special values are supported: off will simply close the corresponding standard handle, and if GIT_REDIRECT_STDERR is 2>&1, standard error will be redirected to the same handle as standard output. windows being windows, but make it iconic ๐ŸชŸ

  • GIT_PRINT_SHA1_ELLIPSIS (deprecated) โ€” if set to yes, print an ellipsis following an (abbreviated) SHA-1 value. This affects indications of detached HEADs (git-checkout(1)) and the raw diff output (git-diff(1)). Printing an ellipsis in the cases mentioned is no longer considered adequate and support for it is likely to be removed in the foreseeable future (along with the variable). bestie it's deprecated, don't get attached ๐Ÿ’€
  • GIT_ADVICE โ€” if set to 0, then disable all advice messages. These messages are intended to provide hints to human users that may help them get out of problematic situations or take advantage of new features. Users can disable individual messages using the advice.* config keys. These messages may be disruptive to tools that execute Git processes, so this variable is available to disable the messages. (The --no-advice global option is also available, but old Git versions may fail when this option is not understood. The environment variable will be ignored by Git versions that do not understand it.) sometimes you just don't want the unsolicited advice, valid ๐Ÿ™ˆ

๐Ÿ’ฌ DISCUSSION ๐Ÿ’ฌ

More detail on the following is available from the Git concepts chapter of the user-manual[3] and gitcore-tutorial(7).

A Git project normally consists of a working directory with a ".git" subdirectory at the top level. The .git directory contains, among other things, a compressed object database representing the complete history of the project, an "index" file which links that history to the current contents of the working tree, and named pointers into that history such as tags and branch heads. it's giving whole personality in one folder ๐ŸŽ€

The object database contains objects of three main types: blobs, which hold file data; trees, which point to blobs and other trees to build up directory hierarchies; and commits, which each reference a single tree and some number of parent commits. the holy trinity honestly ๐Ÿ‘‘

The commit โ€” equivalent to what other systems call a "changeset" or "version" โ€” represents a step in the project's history, and each parent represents an immediately preceding step. Commits with more than one parent represent merges of independent lines of development. family tree but make it version control ๐ŸŒณ

All objects are named by the SHA-1 hash of their contents, normally written as a string of 40 hex digits. Such names are globally unique. The entire history leading up to a commit can be vouched for by signing just that commit. A fourth object type, the tag, is provided for this purpose. sign one thing, cover the whole timeline, main character energy fr fr โœจ

When first created, objects are stored in individual files, but for efficiency may later be compressed together into "pack files". glow-up arc ๐Ÿ“ฆ

Named pointers called refs mark interesting points in history. A ref may contain the SHA-1 name of an object or the name of another ref (the latter is called a "symbolic ref"). Refs with names beginning refs/head/ contain the SHA-1 name of the most recent commit (or "head") of a branch under development. SHA-1 names of tags of interest are stored under refs/tags/. A symbolic ref named HEAD contains the name of the currently checked-out branch. bookmarking your fave moments ๐Ÿ’–

The index file is initialized with a list of all paths and, for each path, a blob object and a set of attributes. The blob object represents the contents of the file as of the head of the current branch. The attributes (last modified time, size, etc.) are taken from the corresponding file in the working tree. Subsequent changes to the working tree can be found by comparing these attributes. The index may be updated with new content, and new commits may be created from the content stored in the index. the index is literally the group chat between your files and your history ๐Ÿฆ‹

The index is also capable of storing multiple entries (called "stages") for a given pathname. These stages are used to hold the various unmerged version of a file when a merge is in progress. conflict era, we've all been there ๐Ÿ˜ญ


๐Ÿ”’ SECURITY ๐Ÿ”’

Some configuration options and hook files may cause Git to run arbitrary shell commands. Because configuration and hooks are not copied using git clone, it is generally safe to clone remote repositories with untrusted content, inspect them with git log, and so on. ngl that's the reassuring part ๐Ÿซถ

However, it is not safe to run Git commands in a .git directory (or the working tree that surrounds it) when that .git directory itself comes from an untrusted source. The commands in its config and hooks are executed in the usual way. like, it WILL run them. no cap. ๐Ÿšจ

By default, Git will refuse to run when the repository is owned by someone other than the user running the command. See the entry for safe.directory in git-config(1). While this can help protect you in a multi-user environment, note that you can also acquire untrusted repositories that are owned by you (for example, if you extract a zip file or tarball from an untrusted source). In such cases, you'd need to "sanitize" the untrusted repository first. ownership is not a vibe check, bestie ๐Ÿ’…

If you have an untrusted .git directory, you should first clone it with git clone --no-local to obtain a clean copy. Git does restrict the set of options and hooks that will be run by upload-pack, which handles the server side of a clone or fetch, but beware that the surface area for attack against upload-pack is large, so this does carry some risk. The safest thing is to serve the repository as an unprivileged user (either via git-daemon(1), ssh, or using other tools to change user ids). See the discussion in the SECURITY section of git-upload-pack(1). stay safe out there ๐Ÿ”ฅ


๐Ÿ“š FURTHER DOCUMENTATION ๐Ÿ“š

See the references in the "description" section to get started using Git. The following is probably more detail than necessary for a first-time user. (lowkey true but we're here anyway ๐Ÿ’…)

The Git concepts chapter of the user-manual[3] and gitcore-tutorial(7) both provide introductions to the underlying Git architecture. start here if you wanna actually get it ๐Ÿง โœจ

See gitworkflows(7) for an overview of recommended workflows. the "how do teams actually do this" doc ๐ŸŽ€

See also the howto[4] documents for some useful examples. examples ate, no notes ๐Ÿ‘‘

The internals are documented in the Git API documentation[5]. for the brave ones ๐Ÿฆ‹

Users migrating from CVS may also want to read gitcvs-migration(7). welcome to the future, we're happy you're here ๐ŸŒˆ

๐Ÿ‘‘ AUTHORS ๐Ÿ‘‘

okay so Gitโ€™s origin story is iconic: it was started by Linus Torvalds, and itโ€™s currently maintained by Junio C Hamano. periodt. โœจ

A whole ton of contributions have come from the Git mailing list <git@vger.kernel.org[6]> ๐Ÿซถ โ€” and if you want the fuller contributor roll call, https://openhub.net/p/git/contributors/summary has you covered.

If youโ€™ve got a clone of git.git itself, the output of git-shortlog(1) and git-blame(1) can show you the authors for specific parts of the project. iykyk ๐Ÿ”

๐Ÿ› REPORTING BUGS ๐Ÿ›

Bug reports go to the Git mailing list <git@vger.kernel.org[6]>, which is where development and maintenance is primarily done. You do not have to be subscribed to the list to send a message there, bestie โ€” just send it ๐Ÿ’Œ

Want to peep previous bug reports and other discussions? The list archive is at https://lore.kernel.org/git.

๐Ÿšจ If an issue is security relevant, disclose it privately to the Git Security mailing list <git-security@googlegroups.com[7]>. Do not do the whole public group-chat thing with security stuff, okay? ๐Ÿ™ˆ

๐ŸŒˆ SEE ALSO ๐ŸŒˆ

๐Ÿ’… GIT ๐Ÿ’…

Part of the git(1) suite. slay. ๐Ÿ‘‘

๐ŸŽ€ NOTES ๐ŸŽ€

  1. Git Userโ€™s Manual โ€” file:///usr/share/doc/git-doc/user-manual.html
  2. Trace2 documentation โ€” file:///usr/share/doc/git-doc/technical/api-trace2.html
  3. Git concepts chapter of the user-manual โ€” file:///usr/share/doc/git-doc/user-manual.html#git-concepts
  4. howto โ€” file:///usr/share/doc/git-doc/howto-index.html
  5. Git API documentation โ€” file:///usr/share/doc/git-doc/technical/api-index.html
  6. git@vger.kernel.org โ€” mailto:git@vger.kernel.org
  7. git-security@googlegroups.com โ€” mailto:git-security@googlegroups.com

Signed, sealed, delivered: Git 2.56.0, dated 2026-09-27, page GIT(1) ๐Ÿซถ๐Ÿ’–

๐Ÿ“ฆ where this page comes from