Git

A distributed version control system

Concepts

commit – save the state of your project (take a snapshot of all files and store a reference to that snapshot)

File States

  • unmodified – file has not been changed
  • modified – file has been changed but not committed
  • staged – file has been marked to go into next commit snapshot
  • committed – file stored in database
  • untracked – files in your working directory that were not in last snapshot and not in staging
  • tracked – files Git knows about: unmodified, modified, and staged file states

Sections of a Git Project

  • working – a single checkout of one version of the project
  • staging – a file, generally in the Git directory, of information about what goes into the next commit (aka index)
  • repository – metadata and database of the project

Git Command Groups

Main Commands

CommandDescription
addAdd file contents to the index
amApply a series of patches from a mailbox
archiveCreate an archive of files from a named tree
bisectUse binary search to find the commit that introduced a bug
branchList, create, or delete branches
bundleMove objects and refs by archive
checkoutSwitch branches or restore working tree files
cherry-pickApply the changes introduced by some existing commits
citoolGraphical alternative to git-commit
cleanRemove untracked files from the working tree
cloneClone a repository into a new directory
commitRecord changes to the repository
describeGive an object a human readable name based on an available ref
diffShow changes between commits, commit and working tree, etc
fetchDownload objects and refs from another repository
format-patchPrepare patches for e-mail submission
gcCleanup unnecessary files and optimize the local repository
gitkThe Git repository browser
grepPrint lines matching a pattern
guiA portable graphical interface to Git
initCreate an empty Git repository or reinitialize an existing one
logShow commit logs
maintenanceRun tasks to optimize Git repository data
mergeJoin two or more development histories together
mvMove or rename a file, a directory, or a symlink
notesAdd or inspect object notes
pullFetch from and integrate with another repository or a local branch
pushUpdate remote refs along with associated objects
range-diffCompare two commit ranges (e.g. two versions of a branch)
rebaseReapply commits on top of another base tip
resetReset current HEAD to the specified state
restoreRestore working tree files
revertRevert some existing commits
rmRemove files from the working tree and from the index
scalarA tool for managing large Git repositories
shortlogSummarize ‘git log’ output
showShow various types of objects
sparse-checkoutReduce your working tree to a subset of tracked files
stashStash the changes in a dirty working directory away
statusShow the working tree status
submoduleInitialize, update or inspect submodules
switchSwitch branches
tagCreate, list, delete or verify a tag object signed with GPG
worktreeManage multiple working trees

Manipulators

CommandDescription
configGet and set repository or global options
fast-exportGit data exporter
fast-importBackend for fast Git data importers
filter-branchRewrite branches
mergetoolRun merge conflict resolution tools to resolve merge conflicts
pack-refsPack heads and tags for efficient repository access
prunePrune all unreachable objects from the object database
reflogManage reflog information
remoteManage set of tracked repositories
repackPack unpacked objects in a repository
replaceCreate, list, delete refs to replace objects

Interrogators

CommandDescription
annotateAnnotate file lines with commit information
blameShow what revision and author last modified each line of a file
bugreportCollect information for user to file a bug report
count-objectsCount unpacked number of objects and their disk consumption
diagnoseGenerate a zip archive of diagnostic information
difftoolShow changes using common diff tools
fsckVerifies the connectivity and validity of the objects in the database
gitwebGit web interface (web frontend to Git repositories)
helpDisplay help information about Git
instawebInstantly browse your working repository in gitweb
merge-treePerform merge without touching index or working tree
rerereReuse recorded resolution of conflicted merges
show-branchShow branches and their commits
verify-commitCheck the GPG signature of commits
verify-tagCheck the GPG signature of tags
versionDisplay version information about Git
whatchangedShow logs with difference each commit introduces

User-facing Interfaces

CommandDescription
attributesDefining attributes per path
cliGit command-line interface and conventions
hooksHooks used by Git
ignoreSpecifies intentionally untracked files to ignore
mailmapMap author/committer names and/or E-Mail addresses
modulesDefining submodule properties
repository-layoutGit Repository Layout
revisionsSpecifying revisions and ranges for Git

External Commands

  • askpass
  • askyesno
  • credential-helper-selector
  • credential-manager
  • credential-manager-core
  • credential-manager-ui
  • flow
  • lfs
  • update-git-for-windows

Also:

  • Interactors
  • Low-level manipulators
  • Low-level interrogators
  • Low-level syncing repos
  • Developer-facing interfaces