CheatSheet Git Commands
Command | Effect | Examples |
---|---|---|
init
|
Initialize a local repo |
git init
|
clone
|
Clone a remote repo |
git clone https://git.ufz.de/oesa/git-exercises.git
|
status
|
View the repo status |
git status
|
show
|
Show different things |
git show
git show v0.1.0
git show 3cda487
|
diff
|
View diffs |
git diff
git diff README.md
git diff 3cda487 c8b0455
|
log
|
Show the repo's history |
git log
git log --all
git log --graph --oneline --all
|
add
|
Stage files |
git add README.md
git add *.md
git add --all
|
reset
|
Un-stage files |
git reset README.md
git reset --all
|
commit
|
Commit staged changes |
git commit
git commit -m "A commit message"
git commit --amend
|
checkout
|
Checkout, e.g. branch |
git checkout main
|
branch
|
List, create, delete branches |
git branch
git branch my-feature
git branch --delete my-feature
|
merge
|
merge branch into current branch |
git merge my-feature
git merge my-feature --no-ff
|
fetch
|
Get remote changes |
git fetch
|
pull
|
Pull changes from remote |
git pull origin main
git pull --all
|
push
|
Push something to remote |
git push -u origin main
git push --tags
|
tag
|
List and create tags |
git tag
git tag v0.1.0
git tag v0.1.0 f3c5a77
|