Git Commands Overview Basics Creating a new repository mkdir project cd project git init git remote add origin git@github.com:yourlogin/your-repo.git git add . git commit -am “new repository” git push -u origin master Cloning existing repository git clone https://github.com/username/your-repo.git Creating branch git checkout -b feature-1 you are now in a branch, you can edit and create new files git add . git commit -am “new feature” Merging branch to master git checkout master git merge feature-1 git push Deleting branch git branch -d feature-x List all branches git branch -a Switch branch git checkout feature-x Switch to master branch git checkout master Listing Remote repositories git remote -v Replacing remote repository in case your remote repository changes, or you want to switch from HTTPS->SSH or SSH->HTTPS git remote remove origin git remote add origin git@github.com:yourlogin/your-repo.git Revert commits revert to last commit: git reset --soft HEAD~1 revert to commit X and don’t forget the final ‘ .’ git checkout . Add this version to the staging area and push to remote git add . git commit -m "Reverting to " git push