Git Cheatsheet

Clone

git clone <path or url to repo>

Create an empty repo

git init

Check if upstream has updates

git fetch

Switch to another branch

git checkout mybranch

Pull upstream updates

git pull

Add a file

git add filename

Move a file

git mv sourcefile destinationfile

Note: You can move a directory or source file or destination file can include directories.

Delete a local branch

git branch -d mybranch

Status

git status

git merge

git merge myBranch

Take all upstream source files

git checkout --ours .
git add .

Keep all local files

git checkout --theirs .
git add .

Leave a Reply

How to post code in comments?