Git Cheat Sheet Legend
<required>
[optionnal]
Get Help!
git help [command]
Learn More!
[Link]
[Link]
[Link]
[Link]
[Link]
Create Update Workflow
From existing data Fetch latest changes from origin
cd ~/projects/myproject git fetch
this does not merge them
git init
git add .
Pull latest changes from origin update
git pull
From existing repo does a fetch followed by a merge branch pull
Apply a patch that someone sent you
git clone ~/existing/repo ~/new/repo git am -3 [Link] checkout fetch
git clone you@[Link]:dir/[Link] In case of conflict, resolve the conflict and
default protocol is ssh git am --resolve branch merge
Remote repository for existing local data
mkdir [Link] && cd [Link]
am
git init --bare [--shared=group]
see help for info
Publish browse
Commit all local changes status change
create publish
Show git commit -a
log
using your
favorite editor commit
Prepare a patch for other developpers init push
Files changed in working directory git format-patch origin show commit
git status clone format-patch
Push changes to origin diff
Changes to tracked files git push [origin] [branch]
branch revert
git diff
Make a version or milestone
Changes between ID1 and ID2 git tag <version_name>
reset
git diff <ID1> <ID2> checkout
History of changes revert
git log Revert
History of changes with files changed Return to the last committed state
git whatchanged git checkout -f | git reset --hard
Who changed what and when in a file ! you cannot undo a hard reset
git blame <file> Revert the last commit
A commit identified by ID git revert HEAD Resolve
git show <ID>
Creates a new commit
Revert specific commit Useful tips merge conflicts Configuration
A specific file from a specific ID git revert $id Get help !!!
Creates a new commit View merge conflicts git config [--global]
git diff <ID>:<FILE> Fix the last commit git help [command] git diff
global is stored in ~/.gitconfig
git commit -a --amend Create empty branch
All local branches View merge conflicts against base file
after editing the broken files git symbolic-ref HEAD refs/heads/newbranch
git branch git diff --base <FILE> [Link] $name
star "*" marks the current branch Checkout the ID version of a file rm .git/index user
[Link] $email
Search for patterns git checkout <ID> <file> git clean -fdx View merge conflicts against other changes
git grep <pattern> [path] <do work> git diff --theirs <FILE>
color [Link] auto
git add your files
View merge conflicts against your changes
git commit -m 'Initial commit' [Link] $user
Branch Graphical log
git diff --ours <FILE>
Discard a conflicting patch
github
[Link] $token
git log --graph
Switch to the BRANCH branch git reset --hard
git log --graph --pretty=oneline --abbrev-commit [Link] 0
git checkout <BRANCH> git rebase --skip optimisation
Push branch to remote [Link] 0
Merge branch B1 into branch B2 After resolving conflicts, merge with do not use on low memory pc
git push <origin> <branch>
git checkout <B2> git add <CONFLICTING_FILE>
Delete remote branch and locally windows [Link] true
git merge <B1> git rebase --continue
git push <origin> :<branch>
Create branch based on HEAD git branch -d <branch>
git branch <BRANCH>
Create branch based on another
git checkout <new> <base> master is the default development branch
Delete a branch origin is the default upstream repository
HEAD is the current branch This work is licensed under a Creative Commons Attribution-Share Alike 3.0 Unported License : [Link]
git branch -d <branch>