The ultimate git cheat sheet to work at lightning speed

12 April 2021

The ultimate git cheatsheet
Photo by danroizer

I created my GitHub account in 2010, 2 years after the end of my studies. I was already a Linux user and I realized I was more productive using the terminal VS clicking everywhere. As a React Native developer, I switched to macOS and I still use the terminal for everything. Today I will share with you my setup to be super-efficient with git and GitHub.

This article provides insight into some of the best tools to use in your day-to-day workflow with the git command line and gets you started with a totally customized setup.

Use ZSH and Oh My ZSH

All UNIX-based operating system comes with a shell called Bash. There are alternatives to Bash that make using the terminal faster and more comfortable for web developers. One of the most popular is Oh My ZSH.

Installing Oh My ZSH is very simple. Simply run the following command and restart your terminal:

sh -c "$(curl -fsSL https://raw.github.com/ohmyzsh/ohmyzsh/master/tools/install.sh)"

ZSH Plugins

ZSH allows you to extend built-in functionality by adding plugins. To enable a plugin, open your .zshrc file and add these:

# Useful oh-my-zsh plugins
plugins=(git gitfast common-aliases zsh-syntax-highlighting history-substring-search zsh-autosuggestions zsh-z)

Getting started with git

Start using git on your project

mkdir awesome_app
cd awesome_app
git init

Status

git status can tell you if your folder has some modified files, but with Oh My ZSH we are using this shortcut

gss

Commit

Saving your work is a 3-steps job. Check the status, git add all and write a commit message

gss
gaa
gcmsg 'feat: add history button closes #123'

Notice using "closes #123" in the commit message will automatically close the issue on GitHub

Diff

If gss tells you something changed, you can inspect exactly what changed

gd

Log

Show commit history with:

glgg
glo
glol

Pushing the changes

gp
Gravatar for dleuliette@gmail.com

Hi, I’m David, a french freelance developer working remotely. I’m the author of this blog, nice to meet you!

Subscribe?

Be the first to receive insightful articles and actionable resources that help you to elevate your skills across every touch point.