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

 

Branching

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)

 

Merging

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

 

Tagging

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)

 

 

 

Tags

Cheat Sheet
Help
Git tutorial
git

Add new comment

CAPTCHA
Answer the below question to help us fight spam

What is the opposite of light?