forward

Git Cheat Sheet

Create repositories

git init [project-name]
create a local repository


git clone [repo-url]
clone a existing remote repository to local machine

Making changes

git add [filename]
add a file to staging area


git add --all
add all files to staging area

git commit -m "[message]"
record changes in version history


git commit -am "[message]"
add all and commit at once

Working with branches

git branch
list all local branches


git branch [name]
create new branch locally

git checkout [name]
switch to another branch


git merge [name]
merge branch into current branch

Remote repository

git remote add [short-form] [repo-url]
add a new remote repository as a short form


git push [remote] [branch-name]
uploads all local commits to remote repository


git pull
incorporates remote changes into local repository