Git is a version control system that is widely used for software development and other version control tasks. It is a distributed revision control system with an emphasis on speed, data integrity, and support for distributed, non-linear workflows. Git was initially designed and developed in 2005 by Linux kernel developers (including Linus Torvalds) for Linux kernel development.
Git GUI client for all major platform (Windows, Linux, OS-X etc) are available on the official Git SCM web site.
Configure user information for all local repositories
git config --global user.name "[name]"
Sets the name you want atached to your commit transactions
git config --global user.email "[email address]"
Sets the email you want atached to your commit transactions
git config --global color.ui auto
Enables helpful colorization of command line output
Start a new repository or obtain one from an existing URL
git init [project-name]
Creates a new local repository with the specified name
git clone [url]
Downloads a project and its entire version history
Working with Local Branch
Review edits and craf a commit transaction
See all commits
git log --no-merges [branch-name]..
See only changes made on particular branch
git log --pretty=format:"%h %s" --graph
Pretty commit view
git status -s
Lists all new or modified files to be commited
Short view of status
Shows file differences not yet staged
git add [file]
Snapshots the file in preparation for versioning
git add .
Add all modified files to be commited
git add '*.txt'
Add only text files
git diff --staged
Shows file differences between staging and the last file version
git reset [file]
Unstages the file, but preserve its contents
git commit -m "[descriptive message]"
Records file snapshots permanently in version history
Name a series of commits and combine completed efforts (Branching)
Lists all local branches in the current repository
git branch [branch-name]
Creates a new branch
git checkout [branch-name]
Switches to the specified branch and updates the working directory
git checkout -b [new-branch-name]
Checkout current branch into a new branch
git merge [branch]
Combines the specified branch’s history into the current branch
git branch -d [branch-name]
Soft deletes the specified branch
git branch -D [branch-name]
Hard deletes the specified branch
See current changes, that have not been staged yet.
git diff HEAD
See current changes, that have not been commited yet (including staged changes)
git diff branch-name
Compare current branch to some other branch
git diff [first-branch]...[second-branch]
Compare two different branches
git show [commit]
Outputs metadata and content changes of the specified commit
Erase mistakes and craf replacement history
git reset [commit]
Undoes all commits afer [commit], preserving changes locally
git reset --hard [commit]
Discards all history and changes back to the specified commit
Shelve and restore incomplete changes
Temporarily stores all modified tracked files
git stash pop
Restores the most recently stashed files
git stash list
Lists all stashed changesets
git stash drop
Discards the most recently stashed changeset
Working with Remote Branch
Manage Remote Branch
See list of remote repos available.
git remote -v
Detailed view of remote repos, with their git urls