For a comprehensive cheat sheet see github's one
cd <directory code is in>
git init
git add filename
git add .
git status
git commit -m "Commit message goes here"
git push origin branch-name
git checkout -b new-branch-name
git checkout existing-branch-name
Get the lastest version of a particular branch from github (if other people committed stuff and pushed it)
git pull origin branch-name Warning pull also merges it the branch you're currently on. If you don't want to merge it, use fetch.
git diff
git diff --cached
Moving is a special operation in git. As well as add and remove.
You can either do a mv file1 file2. But git will think you deleted file1 and created file2. So git status will show two changes. Instead we can do:
git mv file1 file2
This tells git that we're actually moving a file. It shows up as 1 change in git status and makes the history neater later.
git clone the whole thing again into a new folder :p (I do this sometimes :p) and start from there 😄
git reset --hard origin/master <- Goes to github of origin remote, finds master. And completely replaces the current branch you are in with those commits.