Git Cheat Sheet

December 11, 2019

Introduction

A lot of develops say they know Git, some even state that they are Git “experts”. Being an expert might be a streaching a bit for most I would argue. However being an expert in anything is in my opinion very relative and up for debate. None the less I often meet new develops and onboarding develops, who claim their expertice using Git, only to find out that they only comfortable in the trevial git pull, git commit and git push process. And often heavvily rely on their editor providing the buttons to do so.

As such I tend to teach people that Git can do so much more, and that the “basics” (in my opionion) is easy to learn and a valuable for the everyday work as productive developers.

I have gathered a list of git operations / commands and what they do in basic terms as a goto Git Cheat Sheet.

The Basics

Cmd Explanation
git init directory Create empty Git repo in specified directory. Run with no arguments to initialize the current directory as a git repository
git clone <repo> text
git config user.name <name> commonly use --global flag to set config options for current user. Define author name to be used for all commits in current repo. Devs
git add <directory> Replace <directory> with a <file> to change a specific file. Stage all changes in for the next commit.
git commit -m "<message>" Commit the staged snapshot, but instead of launching a text editor, use as the commit message.
git status List which files are staged, unstaged, and untracked.
git log Display the entire commit history using the default format.
git diff Show unstaged changes between your index and working directory

Thomas Kokholm

Thomas Kokholm.
Front-end Developer & UI/UX Specialist. I help customers implement digital solutions that focus on business and high usability.

Copyright © 1999 - 2021. THKO - Thomas Kokholm.