Git Cheatsheet

Senali
2 min readMay 25, 2022

Git is a software for tracking changes in any set of files, usually used for coordinating work among programmers collaboratively developing source code during software development.

git init

Create empty Git repo in specified directory

git clone <repository url>

Clone repo onto local machine

git remote

Show which remotes are currently connected, also to add new connections or remove existing ones

git status

List which files are staged, unstaged, and untracked

git commit -m <'commit messgae'>

Commit the staged snapshot, but instead of launching a text editor, use as the commit message.

git checkout -b <branch name>   |   git checkout <branch name>

Check out a new branch or existing branch.

git merge <branch name>

Join two or more development histories together.

git diff

Show unstaged changes between your index and working directory.

git whatchanged

Show logs with difference each commit introduces

git log

Display the entire commit history using the default format.

git config — global user.name “Your Name”

git config — global user.email “you@address.com”

Define the author username and the email address

git config — list

List all the git configuration

git config — global — edit

Edit global git config file

git fetch && git checkout <branch name>

Checkout to origins branch

rm -rf .git*

Remove GIT version tracking from project

git remote set-url origin <repository url>

Change the URI (URL) of a remote git repository

git rev-list — count <branch name>

Check the commit count of a branch

--

--

Senali

I write about stuff I find interesting. Usually WebDev, DevOps, ML and occasionally Finance