Git Cheat Sheet - Wall Skills1

Download as pdf or txt
Download as pdf or txt
You are on page 1of 1

Create Update Publish

Git Cheat Sheet From existing data


cd ~/projects/myproject
Fetch latest changes from origin
git fetch
this does not merge them
Commit all local changes
git commit -a
git init
Pull latest changes from origin Prepare a patch for other developpers
git add .
git pull git format-patch origin
From existing repo does a fetch followed by a merge
Push changes to origin
git clone ~/existing/repo ~/new/repo Apply a patch that someone sent you git push [origin] [branch]
git clone [email protected]:dir/project.git git am -3 patch.mbox
default protocol is ssh In case of conflict, resolve the conflict and Make a version or milestone
git am --resolve git tag <version_name>
Remote repository for existing local data
mkdir repo.git && cd repo.git
git init --bare [--shared=group]
see help for info

Workflow

update
branch pull
checkout fetch
branch merge
am
browse
status change
create using your publish
log favorite editor commit
init push
show commit
clone format-patch
diff
branch revert
reset
checkout
revert

Branch Revert Show


Switch to the BRANCH branch Return to the last committed state Files changed in working directory
git checkout <BRANCH> git checkout -f | git reset --hard git status
Merge branch B1 into branch B2 ! you cannot undo a hard reset
Changes to tracked files
git checkout <B2> Revert the last commit git diff
git merge <B1> git revert HEAD
Creates a new commit Changes between ID1 and ID2
Create branch based on HEAD
Revert specific commit git diff <ID1> <ID2>
git branch <BRANCH>
Create branch based on another git revert $id History of changes
Creates a new commit git log
git checkout <new> <base>
Fix the last commit
Delete a branch git commit -a --amend History of changes with files changed
git branch -d <branch> after editing the broken files git whatchanged
Checkout the ID version of a file Who changed what and when in a file
master is the default development branch git checkout <ID> <file> git blame <file>
origin is the default upstream repository A commit identified by ID
HEAD is the current branch
git show <ID>
A specific file from a specific ID
git diff <ID>:<FILE>
Licensed under Creative Commons Attribution-Share Alike
3.0 Unported License: creativecommons.org/licenses/- All local branches
git branch
by-sa/3.0/ star "*" marks the current branch
Search for patterns
Original by pastjean: github.com/pastjean/git-cheat-sheet git grep <pattern> [path]

By Pierre-Alexandre St-Jean - http://stjean.me/


Re-arranged by Wall-Skills.com - Informative 1-Pagers

You might also like