SSH Git Commands Cheat Sheet Simple Guide

Ganesh Subramanian
1 min readMar 13, 2020

Generate a new SSH on Mac

ssh-keygen -t rsa -b 4096 -C "your_email@example.com"

After generating add the new SSH key to your GitHub account

Connect via ssh

git -c core.sshCommand="ssh -i ~/.ssh/mac_rsa" clone git@gitlab.com:YourProject/Your.git

Current dir git status

git status

Show checked out branches

git branch

Search for git branch

git branch -a | grep best

Checkout a branch

git checkout [branch name]

Create a new local branch from the current active branch

git checkout -b [new branch name]

Get Latest from Origin

git -c core.sshCommand="ssh -i ~/.ssh/mac_rsa" fetch origin

Get Latest Changes for the Active Branch

git -c core.sshCommand="ssh -i ~/.ssh/mac_rsa" pull

Commit changes to active branch

git commit -m '[your commit message]'

Push changes to origin

git -c core.sshCommand="ssh -i ~/.ssh/mac_rsa" push [branch name]

Running record of commits

git log

Un-stage all files

git checkout — .

Delete branch locally

git branch -d [local branch name]

Delete branch remotely

git -c core.sshCommand=”ssh -i ~/.ssh/mac_rsa” push origin -delete [remote branch name]

Merge branch to active branch

git merge [branch name]

Abort Merge

git merge — abort

List all conflict file names after merge

git diff -name-only -diff-filter=U

--

--