Cheat Sheet

Creating and cloning repo

Create a repository git init
Clone local repository git clone /path/to/repo
Clone remote repository git clone username@host:/path/to/repo


Adding and removing

Add changes to index git add (filename)
Add all changes at once git add .
Remove changes from index git rm (filename)


Committing and Syncing

Commit changes git commit
Push changes to remote repository git push origin master
Connect local repository to remote repository git remote add origin (server)
Update local repository with remote changes git pull



Create new branch git branch
Switch to master branch git switch master
Delete a branch git branch -D branch name
Push branch to remote repository git push origin (branch name)



Merge two branches together git merge (branch name)
View changes between two branches git diff (branch1) (branch2)



Create a tag git tag (commit ID)
Find commit IDs git log


Undoing changes

Reset to a previous commit git reset –hard 48b4f75175dd883458790c6ac
Replace working copy with latest from HEAD git checkout -- (filename)





Cheat Sheet
Git tutorial

Add new comment

Answer the below question to help us fight spam

What is 2 + 2?