new will come along! If you are a beginner, don’t try to understand everything – slides are online and can be used as cheat sheets Personal style and experience, real life examples – there’s more than one way to do things Disclaimer
parent of HEAD history of movement of HEAD, can be seen in git reflog reattach HEAD to tip of branch Don’t lose your HEAD git checkout HEAD~1 git checkout HEAD^1 git checkout HEAD@{1} git checkout <branchname>
--soft HEAD@{1} removes one commit and all work – all uncommitted changes are lost forever undoes one commit and puts the work from that commit back in the workspace
-p stash@{5} git stash branch <branchname> stash@{5} shows content of stash creates a new branch from the commit where stash was created, checks it out and retrieves the stash
commit Creates a new commit that's the inverse of the given hash. Anything removed in the old commit will be added in the new commit. Anything added in the old commit will be removed in the new commit.
reset --soft HEAD^ git stash git checkout <branchname> git stash pop git commit git push origin <branchname> git checkout <wrong_branch> git push --force origin <wrong_branch> make sure you’re in the wrong branch reset the branch back one commit you will need to rewrite the message force push commit deletion to original branch
git merge <other_branch> git reflog git reset --soft <SHA> git add -p go back before the merge, but keep changes in workspace only commit your changes using patch mode
git checkout <xxx> -- will checkout the file will checkout the branch “--” makes clear that the <xxx> part is a branch, everything after “--” must be a file path
-rf .git/ delete repository and create a new one git init git commit . git remote add origin <remote URL> git push remove all Git info from your code manually on GitHub / Bitbucket / Gitlab etc. push code to a new repository
git fetch origin git rebase origin/master git stash git fetch origin git reset --hard origin/master git stash pop delete folder and clone again when someone else changed the history when you have local changes you want to keep when you prefer a clean slate
merge.tool meld commit.template ~/.gitmessage.txt help.autocorrect 50 global gitignore, e.g., “.DS_Store” or “.idea/” set Atom as editor for commit messages set graphical tool for “git mergetool” set default commit message, e.g., “WEB-” accepts typos, e.g., “git pulll” (50 == 5sec)