Git for Darcs Users

The table below lists the corresponding git command for each darcs command.

The GHC project has also started their own git-darcs translation table; you can find it here

Note that git has a concept of the index, which is a set of changes which lives in limbo somewhere between the current state of the workspace and the most recent commit. In darcs, the corresponding concept includes only a list of files that have been darcs added; the actual changes are selected at the time that darcs record is invoked. Because of this, there isn't just a single command corresponding to darcs whatsnew.

For darcs users, the hardest part about learning git is understanding why there are multiple commands corresponding to darcs whatsnew, and what the difference between them is.

The easiest way to understand this is to think of the git index as the set of changes selected via interactive darcs record. The big difference is that in darcs, selection of changes and recording of changes is a single atomic operation; in git these are two distinct operations, and other things may happen between them!

Also, note that darcs add adds files to darcs' list of tracked files; git add adds changes to git's index. A darcs record will ask the user which of the changes to the tracked files should become part of the changeset; git commit will include all indexed changes in the changeset.

darcs init       git init
darcs check      git fsck
darcs repair     git fsck

darcs add        git add
darcs mv         git mv
darcs remove     git rm
darcs revert     git reset --hard            (everything)
                 git checkout -- <filename>  (one file)
darcs unrevert

darcs record     git add --patch && git commit
darcs record -a  git commit -a (implicit "git add" on tracked files)
darcs unrecord   git reset HEAD^

darcs tag        git tag
darcs rollback   git revert

darcs dist       git archive

darcs diff <ver> git diff <ver>    (show changes between specific versions)
darcs whatsnew   git diff HEAD     (show changes since last commit)
                 git diff          (show non-indexed changes)
                 git diff --cached (show indexed changes)

darcs changes    git log
darcs pull       git pull
darcs unpull     git reset --hard REVISION~1
                 git rebase -i REVISON~1 (finer control)

darcs push       git push
darcs send       git send-email
darcs apply      git am
darcs trackdown  git bisect
darcs get        git fetch

The following commands manipulate the index, so they don't correspond to commands in darcs so much as ways of interacting with darcs' hunk-selection prompts:

  • git reset will reset the index to the null set (un-index everything)

  • git update-index –force-remove <file> will un-index the changes in a specific file.

Other Comments

Apparently git push doesn't fully update all the bookkeeping bits of the repository to which it pushes.

The appropriate commands to do so are included in the .git/hooks/ default scripts, but these default scripts are organized differently depending on what version of git was used to create the repository (some versions name them post-update.sample, others name them post-update but simply don't mark them executable).

The commands below will enable the script. Don't worry if the first command fails (that's what the ||true is for).

mv -i .git/hooks/post-update.sample .git/hooks/post-update || true
chmod +x .git/hooks/post-update

A lot of the patch-reordering magic that darcs users are used to having happen automatically can be simulated manually with git rebase –interactive. There's a good guide to it here.

Conversion Tools

I have a separate page with my experiences using some darcs-to-git conversion tools.