Skip to content

Basics

Initial set-up

git init
git remote add origin https://github.com/aldomann/repo.git #Add Git repo to folder
git remote set-url origin git@github.com:aldomann/repo.git #Switch to SSH
git pull origin master
git branch --set-upstream-to origin/master

Commands

git status -s
git add -A
git add -u
git push

Garbage Clean

git gc

Delete every untracked file and directory

git clean -d -f -x

Remove directory from remote repository after adding them to .gitignore

git rm -r --cached some-directory
git commit -m 'Remove the now ignored directory "some-directory"'
git push origin master

Reset repo when having pull conflicts

git fetch --all
git reset --hard origin/master

Helpful URLs