0% found this document useful (0 votes)
848 views

Git Cheatsheet

This document provides a summary of common Git commands organized into categories such as repository management, branching and merging, editing history, viewing information, tags, and collaboration. It lists commands for initializing and cloning repositories, adding remote repositories, checking out and switching branches, merging branches, viewing diffs and status, staging and committing changes, reverting and rebasing commits, and pushing changes to remote repositories.

Uploaded by

Indrajeet
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
848 views

Git Cheatsheet

This document provides a summary of common Git commands organized into categories such as repository management, branching and merging, editing history, viewing information, tags, and collaboration. It lists commands for initializing and cloning repositories, adding remote repositories, checking out and switching branches, merging branches, viewing diffs and status, staging and committing changes, reverting and rebasing commits, and pushing changes to remote repositories.

Uploaded by

Indrajeet
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 1

{ssh,git,https}://server/repos git init [--bare] [--shared]

git Cheatsheet 0.94 Repository on Server Create Repository


Fred Park
[email protected]
git clone {ssh,git,https}://[repo] [dir]
http://randu.org
Inspired from hg cheatsheet by Adrian Sai-wah Tam
Clone Repository
git config [--global] [name] [value]
Configure git Options
/path/to/repos
Repository git config --list
List Configured git Options
git remote [-v] show [repo] git remote add [shortname] [url]
git checkout -b [branch] Show Remote Repositories Add Remote Repository
Create and Switch to New Branch
git pull [repo] [branch] git mergetool
git branch Fetch and Merge Merge Conflict
List Branches and Show Current HEAD
git fetch [--dry-run] [repo] [branch]
git checkout [branch] Update Objects and References
Switch to Branch
git merge [--no-ff] [branch]
git branch -d [branch]
Merge Branch
Delete Branch
/path/to/repos git branch [--merged|--no-merged]
git checkout --track [repo/branch]
Updated Repository Status of Branch Merges
Track Remote Repo Branch
git diff
git checkout [ref] [--] <file> Diff Local Changes
Restore File and Stage git add [-u] [-i] <files>
git reset [ref] [--] <file> Stage Files git status
Unstage File View Status of Files
git rm [--cached] <files>
Remove Files
git commit --amend [-m’msg’]
git diff --staged git commit -a [-m’msg’]
Amend Last Commit
Diff Staged Changes Commit All Local Changes
git reset --soft [ref]
Move HEAD /path/to/repos
git reset [ref] Staged Changes git stash
Move HEAD and Reset Stage Stash Local and Staged Changes
git reset --hard [ref]
git stash list
Move HEAD, Reset Stage and
List Stashes
Local Working Copy (No Undo) git commit [-m’msg’]
git stash apply|pop [--index] [stash@{#}]
Commit Staged Changes
/path/to/repos Apply or Pop Stash #
New Commit git revert [ref] git stash drop [stash@{#}]
Pointing to Commit Revert Commit Drop Stash #
[ref] Reverted to
/path/to/repos
New Revision git rebase [branch]
git archive [--format=][--prefix=] [ref]
Create Archive Rebase Current Branch Commits on to branch

git bundle create <file> [repo/branch] git cherry-pick [ref]


Create Bundle Copy Commit and Apply on Current Branch
git push [--dry-run] [repo] [lref:rref]
Push and Update Remote Refs and Objects
git tag [-a] [-m'msg’] <tag> git log [--oneline] [--graph] [--pretty=]
Create a Tag Show Commit Log

git tag [show <tag>] git grep [-I] [-n] [--cached] [-e pattern] [ref]
List or Show a Tag Find Patterns
Upstream Repository
git tag -d <tag> Repository Updated git blame [-Ls,e] <file>
git push --tags [repo] Show Who Changed What to a File
Delete a Tag
Push Tags to Remote Repo
git bisect [start|bad|good|reset]
Binary Search Through Commits to Find Issues

You might also like