Search AnyKit Tools

Type a tool name, tag, or category to quickly open any tool instantly.

Git Cheat Sheet

New

Commonly used Git commands reference

Click command to copy

Configuration

Set Global Name

$ git config --global user.name "[name]"

Sets the name you want atttached to your commit transactions

Set Global Email

$ git config --global user.email "[email]"

Sets the email you want atttached to your commit transactions

List Config

$ git config --list

List all configuration variables

Starting Repos

Initialize

$ git init

Create a local repository

Clone

$ git clone [url]

Download a project and its entire version history

Commit & Push

Stage All

$ git add .

Add all current changes to the next commit

Commit

$ git commit -m "[message]"

Commit your staged content

Push

$ git push origin [branch]

Push your local commits to the remote

Pull

$ git pull

Fetch and merge any commits from the tracking remote

Branching

Create Branch

$ git branch [name]

Create a new branch

Switch Branch

$ git checkout [name]

Switch to a specific branch

Create & Switch

$ git checkout -b [name]

Create a new branch and switch to it

List Branches

$ git branch

List all local branches

Mistakes & Undo

Amend Message

$ git commit --amend

Change the message of the last commit

Soft Reset

$ git reset HEAD~1

Undo last commit, keep changes staged

Hard Reset

$ git reset --hard HEAD~1

Undo last commit and DISCARD all changes

Stash Changes

$ git stash

Temporarily store all modified tracked files

Need more help?

This is just a quick reference. For deeper documentation, we recommend checking the official Git Documentation or using git help [command] in your terminal.