Resources     Blog  

  1. Home
  2. Git Tutorials
  3. Cheat Sheet For All Things Git

Cheat Sheet For All Things Git

Git is a vast VCS (Version Control System) that gives you the ability to work projects with teams in a very unique way. There are tons of commands and functions to learn. Getting to know and understand how to use Git properly can only happen over time. If you understand what Git is and how it works, then you will have a better understanding of the Git cheat sheet below.

GitHub provides desktop clients that include a graphical user interface for the most common repository actions and an automatically updating command line edition of Git for advanced scenarios.

Here is a little Git cheat sheet for you to reference for all things Git.

GitHub Desktop and Platform Installations

Find the GitHub desktop here:

You can find Git for any platforms here:

If you want to know how to install Git on any platform please review these detailed articles:

How To Install Git on MAC OS and Linux

How To Install Git on Windows

Configure Tooling Commands

Some commands to configure user information for all local repositories.

$ git config –global «[name]»

This sets the name you want attached to your commit transactions.

$ git config –global «[email address]»

This sets the email you want attached to your commit transactions.

Create Repositories

Some commands to start a new repository or obtain one from an existing URL.

$ git init [project-name]

This command creates a new local repository with the specified name.

$ git clone [url]

This command downloads a project and its entire version.

For more information on repositories please review the following articles:

How To Create a Git Repository

How To Manage a Git Repository

How To Inspect a Git Repository

Git Repository Structure

Refactor File Names

Some commands to relocate and remove versioned files.

$ git rm [file]

This command deletes the file from the working directory and stages the deletion.

$ $ git rm –cached [file]

This command removes the file from version control but preserves the file locally.

$ git mv [file-original] [file-renamed]

This command changes the file name and prepares it for commit.

Suppress Tracking

Exclude temporary files and paths.


A text file named .gitignore suppresses accidental versioning of files and paths matching the specified patterns.

$ git ls-files –others –ignored –exclude-standard

This command lists all ignored files in the project.

Save Fragments

Commands to shelve and restore incomplete changes.

$ git stash

This will temporarily store all modifies tracked files.

$ git stash pop

This command restores the most recently stashed files.

$ git stash list

This command lists all stashed changesets.

$ git stash drop

This command discards the most recently stashed changeset.

Make Changes

Commands for reviewing edits and crafting a commit transaction.

$ git status

This command lists all new or modified files to be committed.

$ git diff

This command shows file differences that are not yet staged.

$ git add [file]

This command snapshots the file in preparation for versioning.

$ git diff –staged

This command shows file differences between staging and the last file version.

$ git reset [file]

This command unstages the file, but preserves its contents.

$ git commit -m»[descriptive message]»

This command records file snapshots permanently in version history.

Group Changes

$ git branch

This command lists all local branches in the current repository.

$ git branch [branch-name]

This command creates a new branch.

$ git checkout [branch-name]

This command switches to the specified branch and updates working directory.

$ git merge [branch-name]

This command combines the specified branch’s history into the current branch.

$ git branch -d [branch-name]

This command will delete a specified branch.

Review History

Here are some commands that will allow you to browse and inspect the the evolution of project files.

$ git log

This command lists version history for the current branch.

$ git log –follow [file]

This command lists version history for the file, including renames.

$ git diff [first-branch]…[second-branch]

This command shows content differences between two branches.

$ git show [commit]

This command outputs metadata and content changes of the specified commit.

Redo Commits

Some commands to erase mistakes.

$ git reset [commit]

This command Undoes all commits after [commit], preserving changes locally.

$ git reset –hard [commit]

This command discards all history and changes back to the specified commit.

Synchronize Changes

Some commands to register a remote (URL) and exchange repository history.

$ git fetch [remote]

This command downloads all history from the remote repository.

$ git merge [remote]/[branch]

This command combines the remote branch into the current local branch.

$ git push [remote] [branch]

This command uploads all local branch commits to GitHub.

$ git pull

This command downloads bookmark history and incorporates changes.

A Little More

For an overview of even more top Git commands and examples view this article:

Top 20 Git Commands and Examples

For more detailed information on how to undo changes in Git please read:

How To Undo Changes in Git

There you go. A little Git cheat sheet to help you on your journey.

Author: Jeremy Holcombe

Growing up in Hawaii, Jeremy started his freelance writing career doing resumes, business plans, article writing, and everything in between. He now specializes in online marketing and content writing and is part of the Content Marketing Team at GreenGeeks.

Was this article helpful?

Related Articles

Leave a Comment

Este sitio usa Akismet para reducir el spam. Aprende cómo se procesan los datos de tus comentarios.