Basic git commands

This is for people recovering from Subversion.

Get an existing from the server for the first time

git clone git@example.com:repositoryname

See what's changed

git status

Check in locally

git commit -m "good description"

Push local commits to the server

git push

Get and merge updates from the server

git pull

Stage a file for the next local commit

git add file

Stage all files for the next local commit

git add .

Create a new local branch and check it out

git checkout -b branchname

Switch to a local branch

git checkout branchname

Switch to the previous branch

git checkout -

Overview of local branches

git branch

Delete a local branch

git branch -d branchname

Insert changes on the server before your local changes

git pull --rebase

Temporarily discard local changes

git stash

Re-apply stashed away changes

git stash apply

Re-apply stashed away changes an delete them from stack

git stash pop

Find out who wrote something

git blame filename

Restore a deleted file (notice the space before and after the double dash)

git checkout -- filename

Over 13 years ago