git is a version control system that lets you manage and keep track of your source code history and is responsible for everything GitHub related that happens locally on your computer. GitHub is a cloud-based hosting service that lets you manage Git repositories.
A cheat sheet for Git workflows
Local Setup
Configures user information used across all local repos
Command
What it does
git config --global user.name firstname lastname
sets a name to be associated
git config --global user.email valid-email
sets an email address to be associated
git config --global color.ui
autosets automatic command line color
git config --global init.defaultBranch <name>
sets local initial branch name to use in all new repos
Repo Setup & Init
Configuring user information, initializing and cloning repos
Command
What it does
git init
initializes an existing directory as a git repo
git clone url
retrieves an entire repo from a url
git clone url; cd <local_folder_name>
retrieves an entire repo from a url then creates and saves it to a specified local location
π¬ This section assumes the remote repo is represented by a remote or Git server π¬
Pushing and Pulling
Command
What it does
git clone url
retrieves an entire repo from a url
git clone url; cd <local_folder_name>
retrieves an entire repo from a url then clones it to a specified local folder
git remote add origin<link>
to add a link
git push
to push to your master (or main) branch
git push -u origin master
to push to origin
Branching and Merging
Command
What it does
git checkout -b branchname
to create a new branch
git status
to see everything that's been modified
git merge origin/master
to merge master into your new branch
git branch
to list branches
git branch -a
to list all the branches (might be the same as π)