IT-tools

Git cheatsheet

A compact Git command cheatsheet covering setup, staging, commits, branches, remotes, undo, and history. Copy commands as needed.

Setup
Initialize repositorygit init
Clone repositorygit clone <url>
Set user namegit config --global user.name "<name>"
Set user emailgit config --global user.email "<email>"
Stage & commit
Statusgit status
Stage filegit add <file>
Stage allgit add .
Commitgit commit -m "<message>"
Amend commitgit commit --amend
Branches
List branchesgit branch
Create branchgit branch <name>
Switch branchgit switch <name>
Create and switchgit switch -c <name>
Merge branchgit merge <branch>
Remote
List remotesgit remote -v
Add remotegit remote add origin <url>
Pushgit push -u origin <branch>
Pullgit pull
Fetchgit fetch --all
History & undo
Loggit log --oneline --graph
Unstage filegit restore --staged <file>
Discard changesgit restore <file>
Soft resetgit reset --soft HEAD~1
Stashgit stash push -m "<message>"

// About this tool

Keep common Git commands within reach while working in a terminal. Browse commands grouped by task and copy the exact syntax you need. Commands are grouped by everyday tasks.

// How to use it

  1. Find the task you need, such as branches or remotes.
  2. Review the command syntax.
  3. Copy the command into your terminal.

// Frequently asked questions

Does it run Git commands?

No. It is a reference; commands are copied and run in your own terminal.

Are the commands safe to run?

Read them first, especially destructive commands such as reset or clean.