List of equivalent commands in Git, Mercurial, and Subversion

List of equivalent commands in Git, Mercurial, and Subversion

Whether you work in collaboration with other developers or alone, you need version control. In other words, it is always good practice to use version control when you are programming because it helps you track the changes you or others have made to the code.

The most commonly used open source version control systems are Git, Mercurial, and Subversion. There are a lot of differences between these three. The main difference is that Subversion is a centralized version control system. It uses a central server to store all files and requires developers to checkout of the repository which they update from and commit to. Git and Mercurial, on the other hand, are distributed version control systems. As a result, the latter two have a lot more similar commands with each other than with Subversion.

Read how to host SVN, Git or Mercurial repositories behind your firewall

However, similarities still exist, despite the different workflows. Although the commands used are rarely exactly the same, there are equivalent commands between these three version control systems. So, for your pleasure, we decided to list a few of the most used commands that have equivalents in Git, Mercurial, and Subversion.

This will be particularly useful if you are migrating from one version control system to another, and need to learn the ropes in the new system.

The list below is by no means exhaustive. We'd love to hear what type of similarities you have spotted in these version control systems. Or even if you disagree with the commands.

Git Mercurial Subversion
git add <file> hg add <new_file> (only if the file is not tracked yet) svn add <file> (only if the file is not tracked yet)
git blame <file> hg blame <file> svn blame <file>
git show <rev>:<file> hg cat -r <rev> <file> svn cat -r <rev> <file>
git clone <URL> <target_name> hg clone <URL> <target_name> svn checkout <URL> <target_name>
git commit -a hg commit svn commit
git rm <file> hg rm <file> svn delete <file>
git diff <file> hg diff <file> svn diff <file>
git show HEAD:<directory> hg cat -r rev <directory> svn list <directory>
git merge hg merge svn merge
git checkout <file or directory> hg revert <file or directory> svn revert <file or directory>
git checkout HEAD hg update tip svn switch <url> or svn revert <file>
git checkout <branch> hg update <branch> svn switch <url>
git status hg status svn status
git pull hg pull -u svn update
git init hg init . svnadmin create
git fetch hg pull svn update
git reset --hard hg revert -a --no-backup svn checkout -r <revision> url://path/to/repo
git stash hg shelve No equivalent, may be released in SVN 1.10?, possibly in 2017
git revert <commit_hash|tag|branch_name> hg backout <changeset_num|changeset_hash|tag> svn merge -r UPREV:LOWREV . undo range

svn merge -c -REV . undo single revision

Which version control system suits your needs? Read Git vs. SVN and Git vs. Mercurial.

Seamless software development.

Code management and collaboration platform with Git, Subversion, and Mercurial.

Sign up for free
comments powered by Disqus