Git cheat sheet

Create or clone a repo

git init

Creates a new repository in the current directory

git clone [url]

Clones a repository from the URL specified. Can be HTTPS or SSH. You can specify a folder name after the URL to customize it.

Add some files and commit them

git status

Shows the modified files, the current branch, the staged files.

git add [file]

Stages a file for next commit. File can be replaced by “.”, staging all modified files in the current directory and recursively.

git reset [file]

Unstages a file without altering the modifications.

git diff

Shows modifications made in unstaged files.

git diff --staged

Shows modifications made in staged files.

git commit -m [message]

Commit staged files with the message specified.

Using branches

git branch

Lists all local branches.

git branch [name]

Creates a branch with the specified name.

git switch [name]
git checkout [name]

Moves to the specified branch.

git log

Shows the commit history for the current branch.

Related Posts

A set on git commands in a Linux terminal

Getting started with git CLI

What is a CLI? CLI stands for Command Line Interface. You get to use the Command Line Interface in a terminal application. Whatever system you use there…

Vite logo

An alternative to create-react-app, Vite!

The motivation I’ve been developing with React for years now, and more recently using Typescript. And there is one thing that never changed, and I’m a bit…

Leave a Reply

Your email address will not be published. Required fields are marked *