• Distributed version control system
  • Bookkeeping subdirectory: .git for top-level directory
  • Useful for tracking project history (rather than file history, as with CVS)
  • More powerful than SVN; not as easy to use
  • Does not use a centralized server
  • Every Git working directory is a full-fledged repository
  • Stores snapshots of the repository instead of commits or changesets
  • Known for easy and cheap branching and merging
  • GitHub (free hosting of open-source projects)
  • Sourceforge (offers free Git hosting as well)

Editing files

Checkout a file

git checkout [-f] <path>            # -f: force

Identify which working files have changed

cd <working-dir>
git status

Show all changes to working files

cd <working-dir>
git diff
git diff [-r<rev>] <path>

Check-in a file

git commit [-a] [-m <message>]      # -a: automatically stage all modified files

Resolving conflicts

Create a patch

git format-patch

Apply patch

git apply

Clean unknown files

git clean

Modifying the repository

Create or reinitialize a repository

cd <dir>
git init

Add all files in a directory tree

git add <dir>

Add a file

git add <file>

Remove a file

git rm [-f] <file>                  # -f: force

Rename/copy/move a file

git mv [-f] <file>                  # -f: force

Administrative commands

Create a copy of a repository

git clone <source>

List/create/delete branches

git branch


git merge




  • - Git home page
  • - Git Quick Reference
  • - Git for CVS users
  • - A short Git tutorial


Parent URL: