Cheatsheet: GIT Commands

A table of some useful git commands.

CommandDescription
git initCreate a new local repository
git rm -rf .gitUndo git init
git add filename git add .Add one or more files to staging (index)
git statusList the files you’ve changed and those you still need to add or commit
git commit -m messageCommit changes to head (but not yet to the remote repository)
git logShow commit history. CommitId is the leading characters of the changeset ID, up to 10.
git checkout branchCheckout an exisitng branch
git remote add origin serverAdds remote server so that project can be pushed.
git push add origin masterPush the branch to your remote master repository
git pullFetch and merge changes on the remote server to your working directory
git revert –no-commit commitID..HEADReverts the head to the specified commitID. All changes would not be lost, but will exist as unsaved changes in project.
Other useful GIT Links:

How to push Cloud9 project to GitHub: http://lepidllama.net/blog/how-to-push-an-existing-cloud9-project-to-github/

Great GIT tutorials: https://www.atlassian.com/git/tutorials/what-is-version-control