Blog Post

My Git CLI Cheat Sheet


I created a cheat sheet for the Git Command Line Interface to go along with my Git tutorial for SQL Change Automation video. I find the Git CLI to be very friendly and easier to learn than a GUI interface.


Download git CLI:

git clone <url>


a remote repo (maybe an empty one) into your local directory. Ref.

git init

If not cloning, you might initialize a fresh repo locally.


.gitignore file


git status

Lists modified or added files, with status as to whether

they are staged. Ref.

git add .

Stages all modified or added files. You must stage before

you commit. Ref.

If you want to unstage everything: git reset  Ref.

git commit -m “this is my meaningful message”

Commits staged files. Ref.

git push

Pushes staged files to remote repo. If upstream branch

doesn’t exist, git CLI prints syntax to push to upstream branch with same name

as your local branch: simply copy and paste! Ref.

git pull

Fetches from remote and updates current branch. If using

feature branches, remember to checkout master and pull after you merge a Pull

Request on the upstream repo. Ref.


git checkout -b features/mynewfeaturename

Switches to a newly created branch (the -b tells it to create a new branch. In Azure DevOps (and some other systems), the “/” means that this branch will be logically grouped into a features “folder-like-thing” and the branch will be named mynewfeaturename. Ref.


merge master

Merges the contents of another branch (in this case, it’s

master)into your current branch. Ref.

git checkout master

Switches to existing branch named master (trunk). Ref.

git branch

Lists all local branches. Ref.

git branch -d features/mynewfeaturename

Deletes local branch features/mynewfeaturename. Only works

if you are not in that branch. Ref.


git stash -u

Put away / temporarily removes all modified files. The -u

means it applies also to even recently added untracked files (not yet staged). Ref.

git stash pop

Unpack your stash. Doesn’t matter if you’re in a different

branch from where you stashed. Ref.

Original post (opens in new tab)
View comments in original post (opens in new tab)


You rated this post out of 5. Change rating




You rated this post out of 5. Change rating