CheatSheet

GIT CHEAT SHEET

This cheat sheet features the most important and commonly used Git commands for easy reference.

Index


SETUP

Configuring user information used across all local repositories


UNSET

Removes user information configuration across all local repositories


SETUP & INIT

Configuring user information, initializing and cloning repositories


STAGE & SNAPSHOT

Working with snapshots and the Git staging area

Git status

Shows modified files in working directory, staged for your next commit

git status

Git add

It adds changes to staging area. This command stages the changes made to files and prepares them for the next commit.

Git reset

It resets changes in the working directory.

git reset [file]
git reset --hard HEAD

Git diff

It shows changes between commits, commit and working tree, etc. It also compares the branches.


BRANCH & MERGE

Isolating work in branches, changing context, and integrating changes

Git branch

It lists, creates or deleyes branches in a repository. To delete the branch using git checkout and then run command to delete the branch locally

Git checkout

Switch to another branch and check it out into your working directory

git checkout [branch-name]

Git merge

Merge the specified branch’s history into the current one

git merge [branch]


INSPECT & COMPARE

Examining logs, diffs and object information


SHARE & UPDATE

Retrieving updates from another repository and updating local repos


TRACKING PATH CHANGES

Versioning file removes and path changes


REWRITE HISTORY

Rewriting branches, updating commits and clearing history


TEMPORARY COMMITS

Temporarily store modified, tracked files in order to change branches


IGNORING PATTERNS

Preventing unintentional staging or commiting of files