VCS, GIT

Short guide on how to use Git CLI

I’ve recently switch my workstation from Windows to Mac OS and I failed to find any great and free replacement to TortoiseGIT (GUI for Git). Therefore, I am force to use the command line to manage my repository.

Here are some of the most common commands that I use

Clone existing repo

git clone <ssh or https url>

Create new local repo

git init

Add all files in directory to git

git add -A

Commit with message

git commit -m "Your message"

Update & Push

git push <remote> <branch> (often "origin master")

and now a less common commands

Check the status and active branch

git status

Switch HEAD branch

git checkout (-b if branch is not there) <branch name>

Merge branch to your current HEAD

git merge <branch>

Clone git to non-empty folder

git init
git remote add origin PATH/TO/REPO
git fetch
git checkout -t origin/master

that’s all I need and hopefully you too, if not search Google for “git cheatsheet”