2010-03-08 · in Tech Notes · 398 words

Darcs and Git are both fine distributed version control systems. I used to use Darcs for most of my projects; these days I use Git, which has mostly caught up to Darcs in terms of user interface and is both more flexible and more widely used.

Common commands

darcs init
git init
darcs add X
git add X (but git recurses by default)
darcs revert X
git checkout -- X
darcs wh
git diff HEAD
darcs wh -s
git status
darcs rec X

git commit -p X

Similarly, there's git add -p, if you want to stage changes first. git diff --cached shows what you've got staged.

git commit -a automatically adds modified/deleted files.

darcs changes
git log
darcs changes --last 10
git log -10
darcs unrecord
  • To remove a bad last commit, git reset --soft HEAD^, then git commit -c ORIG_HEAD (the -c ... starts with the old commit message).

  • To add a change you forgot, stage it, then git commit --amend, which merges the current index into the last commit.

darcs push

git push [origin]

then git reset --hard HEAD on master to update working copy — but that will discard local changes! See git-push.txt in the Git distribution for how to do this automatically with a hook, if safe.

Converting a Darcs repo to Git

I've written a more detailed article on this.

Thoughts on Darcs vs. Git