git add
and before git
commit
Setup:
git config
: edit configuration optionsgit init
: create new repositorySee our status:
git status
: see status of files - use often!git log
: see history of commits and their messages, newest firstgit graph
: see a detailed graph of commits. Create this command
with git config --global alias.graph "log --all --graph --decorate --oneline"
git diff
: show difference between working directory and last commitgit diff --staged
: show difference between staging area and last commitgit show <commit>
: inspect individual commitsGeneral work:
git add
:
git commit
: record a version, add it to current branchgit commit --amend
: amend our last commitgit branch
: show which branch we’re ongit branch <name>
: create a new branch <name>git checkout <file>
: checkout last committed version of <file>, losing unstaged changesgit checkout -b <branch-name>
: create a new branch and switch to itgit revert abc123
: create a new commit which reverts commit abc123git reset --soft abc123
: remove all commits after abc123, but keep their modifications as staged changesgit reset --hard abc123
: remove all commits after abc123, permanently throwing away their changesgit merge <branch-name>
: merge branch <branch-name> into current branchgit grep
: search for patterns in tracked filesgit annotate
: find out when a specific line got introduced and by whomgit bisect
: find a commit which broke some functionality