Command Library
Search for what you want to do, or browse the official Git commands organized by workflow.
Setup
git init
Turns your plain folder into a Git repository so you can start saving code history.
Initializes a new Git repository.
git clone
Downloads a full project from GitHub to your computer so you can work on it.
Downloads a project and its entire version history.
Status & History
git status
Tells you which files you've changed, which are ready to be saved, and which are untracked.
Lists all new or modified files to be committed.
git log
A time machine that shows you every save (commit) made in this project's history.
Shows the commit history for the currently active branch.
Saving changes
git add
Tells Git: 'I want to include this specific file in my next save.'
Stages a specific file for the next commit.
git add .
Tells Git: 'I want to save ALL the changes I just made.'
Stages all changed files for the next commit.
git commit
Takes a picture of your staged files and saves them permanently with a message describing what you did.
Records a snapshot of the staging area.
GitHub connection
git remote add origin
Tells your computer where your GitHub repository lives on the internet.
Connects your local repository to a remote server.
Push/Pull
git push
Sends your saved commits from your computer up to GitHub for everyone (or just you) to see.
Uploads local branch commits to the remote repository.
git pull
Downloads any new changes from GitHub and immediately mixes them into your local files.
Fetches and merges changes on the remote server to your working directory.
Branching
git branch
Shows you all the different timelines (branches) in your project and highlights the one you're currently in.
Lists all local branches in the current repository.
git checkout -b
Creates a brand new alternative timeline for your code and immediately moves you into it.
Creates a new branch and switches to it.
git switch
Moves you out of your current branch and into a different one you specify.
Switches to an existing branch.
git merge
Takes all the work from another branch and combines it into the branch you are actively in.
Joins two or more development histories together.
Stash
git stash
Like putting your messy desk into a drawer temporarily so you can work on something else right now.
Temporarily shelves (or stashes) changes you've made to your working copy.
Undo
git restore
Throws away any changes you made to a file since your last save.
Restores working tree files.