VCS Command Guide

I use Mercurial and Git for various different projects.  There is a lot of discussion on the web about which is best; however, in my experience they're both good in different ways and I use different VCSs for different projects as appropriate.  However, since they work in different ways and with slightly different commands, I often find it hard to remember the right command.  Therefore, I thought I'd make this page, which contains a simple reference for how to do things in each version control system.  There may well be errors (especially in the git commands as I use this least often at the moment).

If you notice anything wrong or can fill in any of the gaps, please drop me a note using this form.

Required Reading

HG Init is a good tutorial, but mercurial is pretty easy (and safe) to use. How to use git to lose data should be required reading for any git user - I've lost data that I really didn't want to lose when using git, so since then I've always been a bit nervous.

Start New Project with a copy on a server

Get a project from elsewhere

Add all files

Look for deleted files

Show differences in working tree

Show history

Show differences introduced in the latest revision

Commit all changes

Commit specific files with message

Commit specific changes within File

Get the latest changes into working dir

Push latest changes

Create a new branch

Switch back to the main branch

List available branches

Merge changes from another branch

Show last entries in log

Ignore files with a glob syntax

Revert changes in working tree

Undo commit

Get information about working tree

Show files that have changed

Get revision information

Add an empty directory (if required by toolchain)

Add a new tag to the current revision

Add a tag to a previous revision

List all tags

Get rid of ignored files

Find tagged commits with a given file in the repository

Find commits that modify a given file in the repository

This website is free, but costs me money to run. If you'd like to support this site, please consider making a small donation or sending me a message to let me know what you liked or found useful.