|
Set or show Git configuration options:
git config [ --global ] [ --get ] <name> [ <value> ]git config [ -l | --list ] |
git config --global user.name "Firstname Lastname"git config --global user.email "firstname.lastname@org.com"|
Initialise a local repository:
git init |
|
Clone a remote repository:
git clone <URL> [ <local_dir> ]The URL can use HTTP or SSH etc. |
|
Show the working tree status:
git status [ -s | --short ] |
|
Add files from the working folder to the index:
git add <filespec> |
|
Save changes from the index to the repository:
git commit [ -a ] [ -m <message> ] |
|
Show changes between references:
git diff [ --staged ] [ --no-renames ] |
|
Show commit logs:
git log [ -<n> ] [ --oneline ] [ --patch ] [ <branch> ] |
|
Remove files from working tree and index:
git rm [ --cached ] <filename> |
|
Move or rename a file:
git mv <filename> <destination> |
|
Reset current HEAD in the repository:
git reset [ --soft | --mixed | --hard ] <sha1> |
|
Add and track remote repositories:
git remote add <remote> <URL> |
|
List remote repositories:
git remote [ -v | --verbose ] |
|
Update local repositories:
git pull [ <remote> [ <branch> ] ] |
|
Update remote repositories:
git push [ -u ] [ <remote> [ <branch> ] ] |
|
Download changes from remote repository:
git fetch [ <remote> [ <branch> ] ] |
|
List, create, rename and delete branches:
git branch [ --all ] [ [ -m [ <oldbranch> ] ] | [ -d ] | [ -D ] <branch> ] |
|
Switch branches:
git checkout [ -b ] [ --track ] <branch> |
|
Join branch histories together:
git merge <branch> |
|
Rebase your branch:
git rebase [ -i ] <branch> | <commit> |
|
Tag a commit:
git tag [ -a ] <tag> [ -m <message> ] |
|
Compare branches:
git diff <branch1> <branch2> |
|
Stash the changes from the working tree:
git stash [ -u ]git stash [ list | show | pop ] [ <stash> ] |
|
Show the contents of objects in the repository:
git cat-file -t | -p <sha1> |
|
Count the number of objects in the repository:
git count-objects |
git show-ref <branch> |
|
Find common ancestor commit:
git merge-base <branch1> <branch2> |
|
Copy specific commits:
git cherry-pick <commit> |
|
List remote references:
git ls-remote |
|
Set files to no longer track changes:
git update-index --assume-unchanged <file> |
No comments yet.
Cheatography n. The art of mapping complex subjects into clear, instantly navigable reference guides.