Here are some of the commands you may need while using Git which is a distributed version control system:# git init
initializes a new repository (creates .git directory and whatsnot inside).# git add .
adds all files under the current directory to be tracked by Git.# git rm -f --cached filename
use if you accidentally added a file to be tracked by git, but have not committed it yet. (see # man gitignore
to specify which files to be ignored.# git commit
commits the changes.# git diff
shows you what's changed.# git status
similar to 'git list', but this also lists any files you haven't ignored or told git about. Also shows which branch you are in at the top.# git clean
removes files not tracked by git. You can add files not tracked by git to .gitignore if you want to keep them to be untracked.# git checkout
shows which files have not been changed and thus need to be merged.# git checkout filename
checks out a file from repository and replaces it thus returning to the rep. version.# git [rm | mv | add] file/dir
tell git when you add/remove/move a file.# git commit -a [-m 'message']
commits all changes (with a message).# git commit -v
shows the whole patch in an editor.# git commit --amend
amends the last commit.# git reset HEAD^
resets the last commit.# git log
shows log.# git blame file
shows what revision and which author modified each line of a file.# git show rev [/path/to/file/or/dir]
pretty self explaining.# git checkout rev
checks out a revision.# git clone url
gets the code from a distribution repository.# git fetch
gets the changes. They are not merged with your local copy yet.# git pull
get & merge the changes.git-archive --format=tar --verbose HEAD | gzip > arc.tar.gz
creates archive of the latest revision.
A bare repository in the git context means a repository not tied to a working copy. It is only the .git directories.
In git, commit = revision = changeset all describe similar terms.
Git Cheatsheet