git(1) — The Stupid Content Tracker
Reference, not a lesson — condensed from the official Git manual page git(1). The numbered course pages teach the model; this records what the manual says. Checked against Git 2.48.1: nothing on this page depends on a newer release.
The primary manual page for the Git suite (git). 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.
High-level tutorials and references:
- Git-Tutorial-Man-Page (
gittutorial[7]): Getting started with imports, commits, branches, and collaboration. - Git-Core-Tutorial-Man-Page (
gitcore-tutorial[7]): Low-level plumbing mechanics, object database, index state, and 3-way merges.
Synopsis
git [-v | --version] [-h | --help] [-C <path>] [-c <name>=<value>]
[--config-env=<name>=<envvar>] [--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>] [--attr-source=<tree-ish>] <command> [<args>]
Options & Flags
-v, --version: Print the Git suite version and exit.-h, --help: Print synopsis and common commands. If-aor--allis specified, list all available commands. If a command name is given, open its manual page.-C <path>: Run as if Git was started in<path>instead of current working directory. Multiple-Coptions evaluate sequentially.-c <name>=<value>: Pass a configuration parameter overriding configuration file settings. Omitting=valuesets the boolean totrue. Settingname=sets it to false/empty.--config-env=<name>=<envvar>: Pass configuration variable populated from the specified environment variable (avoids exposing sensitive credentials in process listings).--exec-path[=<path>]: Path to Git core executable binaries. Unset parameter prints current default path and exits.--html-path/--man-path/--info-path: Print paths to Git’s HTML, man, or info documentation files and exit.-p, --paginate: Pipe output intoless(or$PAGER) if stdout is a TTY.-P, --no-pager: Do not pipe Git output into a pager.--git-dir=<path>: Set path to repository (.gitdirectory). Disables automatic top-level repository discovery.--work-tree=<path>: Set path to the root of the working tree.--namespace=<name>: Set the Git namespace (equivalent toGIT_NAMESPACE).--bare: Treat repository as a bare repository (setsGIT_DIRto current directory if not already set).--no-replace-objects: Ignore replacement refs (equivalent toGIT_NO_REPLACE_OBJECTS).--no-lazy-fetch: Disable on-demand object fetching from promisor remotes in partial clones (GIT_NO_LAZY_FETCH=1).--no-optional-locks: Skip optional background operations requiring file locks (GIT_OPTIONAL_LOCKS=0).--no-advice: Disable advice/hint messages printed by commands.--literal-pathspecs: Treat pathspecs literally without globbing (GIT_LITERAL_PATHSPECS=1).--glob-pathspecs/--noglob-pathspecs: Force enabling or disabling wildcards/globbing on pathspecs.--icase-pathspecs: Treat pathspecs as case-insensitive (GIT_ICASE_PATHSPECS=1).--list-cmds=<group>[,<group>...]: List internal commands by group (e.g.,builtins,main,others,alias,config).--attr-source=<tree-ish>: Read.gitattributesfrom<tree-ish>instead of the working tree.
Command Classifications
Git commands are divided into High-level (Porcelain) commands designed for user workflows and Low-level (Plumbing) commands designed for scripting and tool creation.
High-Level Commands (Porcelain)
Main Porcelain Commands
add: Add file contents to the index (staging area).am: Apply a series of patches from a mailbox.archive: Create an archive of files from a named tree.bisect: Binary search to find the commit that introduced a bug.branch: List, create, or delete branches.bundle: Move objects and refs by single-file archive.checkout: Switch branches or restore working tree files.citool: Graphical alternative togit-commit.clean: Remove untracked files from working tree.clone: Clone a repository into a new directory.commit: Record changes to the repository.describe: Give an object a human-readable name based on closest tag.diff: Show changes between commits, commit and working tree, etc.fetch: Download objects and refs from another repository.format-patch: Prepare patches for e-mail submission.gc: Cleanup unnecessary files and optimize local repository.grep: Print lines matching a pattern.gui: Portable graphical interface to Git.init: Create an empty Git repository or reinitialize an existing one.log: Show commit logs.maintenance: Run tasks to optimize Git repository data.merge: Join two or more development histories together.mv: Move or rename a file, directory, or symlink.notes: Add or inspect object notes.pull: Fetch from and integrate with another repository/branch.push: Update remote refs along with associated objects.range-diff: Compare two commit ranges.rebase: Reapply commits on top of another base tip.reset: Reset current HEAD to a specified state (modifies branch tip/index/working tree).restore: Restore working tree files from index or commit without updating branch.revert: Revert existing commits by creating new inverse commits.rm: Remove files from working tree and index.scalar: Management tool for large Git repositories.shortlog: Summarizegit logoutput.show: Show various types of objects (commits, tags, trees, blobs).sparse-checkout: Reduce working tree to a subset of tracked files.stash: Stash changes in a dirty working directory.status: Show working tree status.submodule: Initialize, update, or inspect submodules.switch: Switch branches cleanly.tag: Create, list, delete, or verify GPG-signed tags.worktree: Manage multiple working trees linked to one repository.gitk: Git repository browser GUI.
Ancillary Commands
- Manipulators:
config: Get and set repository or global options.fast-export: Export repository history.fast-import: Backend for fast Git data importers.filter-branch: Rewrite branches.mergetool: Run merge conflict resolution tools.pack-refs: Pack heads and tags for efficient repository access.prune: Prune unreachable objects.reflog: Manage reflog information.refs: Low-level access to refs.remote: Manage set of tracked repositories.repack: Pack unpacked objects into packfiles.replace: Create, list, or delete refs to replace objects.
- Interrogators:
annotate/blame: Show commit and author information per file line.bugreport: Collect information to file a bug report.count-objects: Count unpacked objects and disk usage.diagnose: Generate a zip archive of diagnostic information.difftool: Show changes using external diff tools.fsck: Verify connectivity and validity of repository objects.help: Display help information.instaweb: Browse repository in web browser viagitweb.merge-tree: Perform merge without touching index/worktree.rerere: Reuse recorded resolution of conflicted merges.show-branch: Show branches and their commits.verify-commit/verify-tag: Check GPG signatures.version: Display version information.whatchanged: Show commit log with diffs.gitweb: Git web frontend interface.
Interacting with Foreign Systems
archimport: Import GNU Arch repository.cvsexportcommit: Export single commit to CVS.cvsimport: Import CVS repository.cvsserver: CVS server emulator.imap-send: Send patch collection to IMAP folder.p4: Import/submit to Perforce repositories.quiltimport: Apply quilt patchset onto branch.request-pull: Generate summary of pending changes.send-email: Send patches as emails.svn: Bidirectional operation between Subversion and Git.
Low-Level Commands (Plumbing)
Manipulation Commands
apply: Apply patch to files or index.checkout-index: Copy files from index to working tree.commit-graph: Write/verify commit-graph files.commit-tree: Create a new commit object.hash-object: Compute SHA object ID and optionally create object in object store.index-pack: Build pack index file for packed archive.merge-file: Run three-way file merge.merge-index: Run merge for files needing merging.mktag: Create tag object with extra validation.mktree: Build tree object fromls-treeformatted text.multi-pack-index: Write and verify multi-pack-indexes.pack-objects: Create packed archive of objects.prune-packed: Remove extra loose objects present in packs.read-tree: Read tree information into index.replay: Replay commits on new base.symbolic-ref: Read, modify, delete symbolic refs.unpack-objects: Unpack objects from pack archive.update-index: Register working tree contents to index.update-ref: Safely update object name stored in a ref.write-tree: Create tree object from current index.
Interrogation Commands
cat-file: Provide contents or details of objects.cherry: Find commits not yet applied upstream.diff-files/diff-index/diff-tree: Low-level diffing utilities.for-each-ref: Output formatted details on refs.for-each-repo: Run command across list of repositories.ls-files: List files in index and working tree.ls-remote: List references in remote repository.ls-tree: List contents of a tree object.merge-base: Find common ancestor for merges.name-rev: Find symbolic names for given revs.rev-list: List commits in reverse chronological order.rev-parse: Pick out and parse parameters/object specs.show-ref: List references in local repository.var: Show Git logical variables.verify-pack: Validate packed Git archive files.
Syncing Repositories & Helpers
daemon: Simple server for Git repositories.fetch-pack: Receive missing objects from another repo.http-backend: Server-side HTTP transport implementation.send-pack: Push objects over Git protocol.update-server-info: Update auxiliary info file for dumb servers.- Server transfer helpers:
http-fetch,http-push,receive-pack,upload-pack,upload-archive,shell.
Internal Helper Commands
check-attr: Display gitattributes information.check-ignore: Debug.gitignorerules.check-mailmap: Show canonical names/emails via mailmap.check-ref-format: Validate reference name formats.credential/credential-cache/credential-store: Credential helpers.hook: Execute Git hooks.interpret-trailers: Add or parse structured commit trailers.stripspace: Clean up whitespace.
Configuration Hierarchy & Files
Git uses INI-formatted text files with sections and key-value parameters:
[core]
filemode = false
[user]
name = "Tony"
email = "tony@example.com"
Configuration Resolution Order (Precedence)
- Command-line Level: Passed via
-c <name>=<value>or--config-env. - Worktree Level:
$GIT_DIR/config.worktree(ifextensions.worktreeConfigis enabled). - Local (Repository) Level:
$GIT_DIR/config. - Global (User) Level:
$HOME/.gitconfigor$XDG_CONFIG_HOME/git/config(overridden byGIT_CONFIG_GLOBAL). - System Level:
$(prefix)/etc/gitconfigor/etc/gitconfig(overridden byGIT_CONFIG_SYSTEMor skipped viaGIT_CONFIG_NOSYSTEM=true).
Repository Layout & Key File Locations
Detailed in gitrepository-layout(5). By default, repository internals reside under .git/ (or $GIT_DIR):
$GIT_DIR/index: Staging area cache file.$GIT_DIR/objects/: Content-addressed object database (blobs,trees,commits,tags).$GIT_DIR/refs/: Pointer files (refs/heads/,refs/tags/,refs/remotes/).$GIT_DIR/HEAD: Reference file pointing to active branch or detached commit SHA.$GIT_DIR/config: Per-repository configuration file.$GIT_DIR/hooks/: Execution scripts triggered by Git actions.
Identifier Syntax & Default Values
Terminology Identifiers
<object>: Object name (40-char SHA or ref) for any Git object type.<blob>/<tree>/<commit>/<tag>: Object names for specific types.<tree-ish>: Evaluates to a tree object (accepts tree, commit, or tag dereferencing to a tree).<commit-ish>: Evaluates to a commit object (accepts commit or tag dereferencing to a commit).HEAD: Points to current branch tip or active commit.
Key Default Settings
- Object Hash Format:
sha1(configurable viaGIT_DEFAULT_HASHor--object-format). - Ref Storage Backend:
files(configurable viaGIT_DEFAULT_REF_FORMATorreftable). - Index Version: Version 2 or 3.
GIT_PROGRESS_DELAY:1second.GIT_OPTIONAL_LOCKS:1(enabled).GIT_REF_PARANOIA:1(enabled).
Environment Variables
Repository Structure & Paths
GIT_DIR: Path to.gitdirectory.GIT_WORK_TREE: Path to root of working tree.GIT_INDEX_FILE: Alternate index location (default$GIT_DIR/index).GIT_INDEX_VERSION: Specifies index format version on write.GIT_OBJECT_DIRECTORY: Alternate directory for primary object store (default$GIT_DIR/objects).GIT_ALTERNATE_OBJECT_DIRECTORIES: Colon-separated (semicolon on Windows) list of read-only shared object stores.GIT_CEILING_DIRECTORIES: List of absolute paths Git should not traverse up when searching for a repository.GIT_DISCOVERY_ACROSS_FILESYSTEM: Boolean flag allowing Git to cross filesystem boundaries when discovering.git.GIT_COMMON_DIR: Common directory for multi-worktree repository objects/refs.GIT_NAMESPACE: Sets Git namespace.GIT_DEFAULT_HASH: Default object hashing algorithm (sha1orsha256).GIT_DEFAULT_REF_FORMAT: Default reference backend format (filesorreftable).
Commit & Author Identity
GIT_AUTHOR_NAME/GIT_AUTHOR_EMAIL/GIT_AUTHOR_DATE: Author metadata override.GIT_COMMITTER_NAME/GIT_COMMITTER_EMAIL/GIT_COMMITTER_DATE: Committer metadata override.EMAIL: Fallback user email address.
Execution, Pagers & Editors
GIT_PAGER: Pager binary override (overridesPAGER).GIT_EDITOR/GIT_SEQUENCE_EDITOR: Text editor binary overrides (for commit messages and interactive rebase).GIT_SSH/GIT_SSH_COMMAND/GIT_SSH_VARIANT: Custom SSH binary or invocation command.GIT_SSL_NO_VERIFY: Disables HTTPS SSL certificate verification when true.GIT_ASKPASS: Binary executable for non-interactive credential prompting.GIT_TERMINAL_PROMPT: Set to0/falseto disable terminal password prompts.
Diffs & Merges
GIT_DIFF_OPTS: Override default diff context options.GIT_EXTERNAL_DIFF: Invokes external command for diff evaluation.GIT_EXTERNAL_DIFF_TRUST_EXIT_CODE: If true, respects exit code 0 (equal) vs 1 (different).GIT_MERGE_VERBOSITY: Numeric controls for merge log output details.
Tracing & Debugging
GIT_TRACE: General trace messages (stdout, file descriptor, or log path).GIT_TRACE_FSMONITOR: Trace filesystem monitor calls.GIT_TRACE_PACK_ACCESS: Log pack accesses and offsets.GIT_TRACE_PACKET/GIT_TRACE_PACKFILE: Network wire packet and packfile logging.GIT_TRACE_PERFORMANCE: Trace command timing and performance metrics.GIT_TRACE_SETUP: Log internal repository setup details.GIT_TRACE_CURL: Verbose transport HTTP/cURL log.GIT_TRACE2/GIT_TRACE2_EVENT/GIT_TRACE2_PERF: Structured Trace2 logging engine.GIT_TRACE_REDACT: Set tofalseto prevent redaction of authorization headers and cookies in trace logs.
Behavior & Safety Controls
GIT_NO_REPLACE_OBJECTS: Disable replace refs.GIT_LITERAL_PATHSPECS/GIT_GLOB_PATHSPECS/GIT_ICASE_PATHSPECS: Pathspec behavior toggles.GIT_NO_LAZY_FETCH: Prevent automatic object fetching in partial clones.GIT_REF_PARANOIA: Set to0to ignore broken refs during traversal.GIT_OPTIONAL_LOCKS: Set to0to prevent background tasks from locking index files.
See Also
- Git-Tutorial-Man-Page (
gittutorial[7]) - Git-Core-Tutorial-Man-Page (
gitcore-tutorial[7])