Command Library

Search for what you want to do, or browse the official Git commands organized by workflow.

Try

16 commands

Setup

git init

git init

Turns your plain folder into a Git repository so you can start saving code history.

Initializes a new Git repository.

git clone

git clone <url>

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

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

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

git add <file>

Tells Git: 'I want to include this specific file in my next save.'

Stages a specific file for the next commit.

git add .

git add .

Tells Git: 'I want to save ALL the changes I just made.'

Stages all changed files for the next commit.

git commit

git commit -m "message"

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

git remote add origin <url>

Tells your computer where your GitHub repository lives on the internet.

Connects your local repository to a remote server.

Push/Pull

git push

git push origin main

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

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

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

git checkout -b <branch_name>

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

git switch <branch_name>

Moves you out of your current branch and into a different one you specify.

Switches to an existing branch.

git merge

git merge <branch_name>

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

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

git restore <file>

Throws away any changes you made to a file since your last save.

Restores working tree files.