Git
Still have trouble with Advanced Git remotes.
Basics
git init
git status
git add
git commit
git log
git log --all --graph --decorate(Visualizes history as a DAG)
git diff <filename> : show changes you made relative to the staging area
git diff <revision> <filename> : show differences in a file between snapshots
git checkout
Branching and merging
git branch
git branch <name> : create a branch
git checkout -b <name> : create a branch and switches to it
git merge <revision> : merges into current branch
git mergetool : use a fancy tool to help resolve merge conflicts
git rebase : rebase set of patches onto a new base
Remotes
git remote : list remotes
git remote add <name> <url>: add a remote
git push <remote> <local branch>:<remote branch> : send objects to remote, and update remote reference
git branch --set-upstream-to=<remote>/<remote branch> : set up correspondence between local and remote branch
git fetch : retrieve objects/references from a remote
git pull : git fetch + git merge
git clone : download repository from remote
Undo
git commit --amend : edit a commit’s contents/message
git reset HEAD <file> : unstage a file
git checkout -- <file> : discard changes
Advanced Git
git config : Git is highly customizable
git clone --depth=1 : shallow clone, without entire version history
git add -p : interactive staging
git rebase -i : interactive rebasing
git blame : show who last edited which line
git stash : temporarily remove modifications to working directory
git bisect : binary search history (e.g. for regressions)
.gitignore : specify intentionally untracked files to ignore
Resources
All articles in this blog are licensed under CC BY-NC-SA 4.0 unless stating additionally.