LinuxCommandLibrary
GitHubF-DroidGoogle Play Store

git

Distributed version control system for tracking code changes

TLDR

Clone a repository
$ git clone [https://github.com/owner/repo.git]
copy
Stage and commit changes
$ git add . && git commit -m "[message]"
copy
Push to remote
$ git push origin [branch]
copy
Pull changes
$ git pull
copy
Create and switch branch
$ git checkout -b [branch-name]
copy

SYNOPSIS

git [options] command [args]

DESCRIPTION

git is a distributed version control system for tracking changes in source code. It enables collaboration through branching, merging, and remote repositories while maintaining complete history.Git's distributed nature means every clone contains full history. Branches are lightweight, enabling feature development workflows. The staging area provides fine-grained commit control.

PARAMETERS

init

Create an empty Git repository or reinitialize an existing one.
clone URL
Clone a repository into a new directory.
add FILES
Stage files for commit.
commit
Record changes to repository.
status
Show working tree status.
diff
Show changes between commits, the working tree, and the index.
push
Update remote refs and associated objects.
pull
Fetch and merge from remote.
fetch
Download objects and refs from another repository without merging.
checkout
Switch branches or restore working tree files.
switch
Switch branches.
branch
List, create, or delete branches.
merge
Join two or more development histories together.
rebase
Reapply commits on top of another base tip.
log
Show commit history.
remote
Manage the set of tracked repositories.
-v, --version
Print the Git suite version.
-C PATH
Run as if git was started in PATH instead of the current directory.
-c NAME=VALUE
Pass a configuration value for the duration of the command.
-p, --paginate
Pipe output into a pager (usually `less`).
--git-dir PATH
Set the path to the repository's `.git` directory.
--work-tree PATH
Set the path to the working tree.
--help
Display help information.

CONFIGURATION

~/.gitconfig

Global user configuration including identity, aliases, and default behaviors.
.git/config
Repository-specific configuration for remotes, branches, and local settings.
~/.gitignore_global
Global ignore patterns applied to all repositories.

INSTALL

sudo apt install git
copy
sudo dnf install git
copy
sudo pacman -S git
copy
sudo apk add git
copy
sudo zypper install git
copy
brew install git
copy
nix profile install nixpkgs#git
copy

CAVEATS

Learning curve for advanced features. Large binary files need git-lfs. History rewriting affects collaborators.

HISTORY

Git was created by Linus Torvalds in 2005 for Linux kernel development after BitKeeper licensing issues. It has become the standard version control system for most software projects.

SEE ALSO

gh(1), git-commit(1), git-push(1), git-log(1), git-branch(1)

RESOURCES

Copied to clipboard
Kai