git
Manage code versions and collaborate
TLDR
Create an empty Git repository
Clone a remote Git repository from the internet
View the status of the local repository
Stage all changes for a commit
Commit changes to version history
Push local commits to a remote repository
Pull any changes made to a remote
Reset everything the way it was in the latest commit
SYNOPSIS
git [--version] [--help] [-C <path>] [-c <name>=<value>] [--exec-path[=<path>]] [--html-path] [--man-path] [--info-path] [-p | --paginate | -P | --no-pager] [--no-replace-objects] [--bare] [--git-dir=<path>] [--work-tree=<path>] [--namespace=<name>] [--config-key=.path=.value] [--literal-pathspecs] [--glob-pathspecs] [--relative] [<command> [<args>...]]
PARAMETERS
--version, -v
Print Git version and exit
--help, -h
Display help for command or subcommand
-C <path>
Run as if started in <path> instead of current directory
-c <name>=<value>
Pass config parameter temporarily for this command
--exec-path[=<path>]
Path to Git executables; override with argument
--html-path
Print path to HTML documentation
--man-path
Print path to man pages
--info-path
Print path to info pages
-p, --paginate
Pipe output through pager
-P, --no-pager
Do not pipe output through pager
--no-replace-objects
Do not use replacement refs
--bare
Treat as bare repository (no working directory)
--git-dir=<path>
Use <path> for .git directory
--work-tree=<path>
Set path to working tree
--namespace=<name>
Prefix refs with <name>/
--literal-pathspecs
Treat pathspecs literally (no globbing/relative)
--glob-pathspecs
Enable globbing for pathspecs (default)
--relative
Print paths relative to current directory
DESCRIPTION
Git is a free, open-source distributed version control system created for handling projects of all sizes with exceptional speed and efficiency. Unlike centralized systems like SVN or CVS, every developer has a full copy of the repository, enabling offline work, easy branching, and merging. Key features include cheap local branching, staging areas for precise commits, and powerful history rewriting tools.
Developed by Linus Torvalds in 2005 for Linux kernel versioning after BitKeeper's withdrawal, Git quickly became the industry standard. It powers massive codebases like the Linux kernel, Android, and Ruby on Rails. The git command is the main entry point, dispatching to subcommands such as git commit, git push, git clone, and hundreds more. Repositories consist of a working directory, index (staging area), and .git directory storing objects and refs.
Git emphasizes content-addressable storage using SHA-1 hashes, packfiles for compression, and protocols like HTTP, SSH, and Git for data transfer. Configuration is flexible via git config, supporting system, global, and local levels. While powerful, its distributed nature requires understanding concepts like remotes, tags, and rebasing for effective use.
CAVEATS
Git has a steep learning curve for branching/merging; repositories grow large without garbage collection (git gc); SHA-256 transition ongoing; sensitive data in history requires git filter-branch or BFG.
COMMON SUBCOMMANDS
git init: Initialize repo
git clone: Copy repo
git add: Stage changes
git commit: Record changes
git push: Upload changes
git pull: Fetch and merge
CONFIGURATION
Use git config --global user.name "Name" for defaults. Levels: system (/etc/gitconfig), global (~/.gitconfig), local (.git/config). View with git config --list.
HISTORY
Created by Linus Torvalds in April 2005 for Linux kernel after BitKeeper license issues. Version 0.99 released days later. Junio C Hamano took maintenance in 2005, leading 2.x releases. Now at 2.46+ with features like partial clones, SHA-256, and bundle-URI. Over 20 years, evolved from kernel tool to universal VCS.


