See also http://rogerdudler.github.io/git-guide/ or https://git-scm.com/book/en/v2/Git-Commands-Setup-and-Config
### Initialize a repository ###
# Initialize a git repository in an existing directory
git init
### Setup git with RStudio/SSH ###
# RStudio
RStudio -> Tools -> Global Options -> Git/SVN -> Create RSA Key -> Create -> Copy the key
# GitHub
Your Profile -> SSH and GPG keys -> New SSH key
### Setup new GitHub repository ###
Select “New repository” (click the + sign). Follow the onscreen instructions.
### Stage your files ###
# Stage all changes
git add .
# Add a remote repository (e.g. GitHub)
git remote add origin [GitHub link]
### Commit your files ###
git commit -m “Commit message”
### git pull ###
# Pull initial remote work from GitHub
git pull [GitHub link]
### git push ###
# Publish to external server (e.g. GitHub)
git push origin master
# Add an upstream reference if Pull and Push buttons are greyed out in RStudio
# Also, see https://www.r-bloggers.com/things-i-forget-pushpull-greyed-out-in-rstudio/
git push -u origin master
### git checkout ###
# Create a new branch and switch to it
git checkout -b [name of branch]
# Switch back to master
git checkout master
### git branch ###
# Delete local branch
git branch -d [name of branch]
# Delete remote branch
git branch -dr origin/[name of branch]
### git status ###
# Show the working tree status
https://git-scm.com/docs/git-status
### Untrack a file ###
git rm –cached [filename]
### List tracked files ###
git ls-files