Version 7 (modified by nominolo, 9 years ago) (diff)


Git for Darcs Users

Just like Darcs, every Git command comes with a --help option. For example git add --help. You can also check out the official Git documentation.

Also see "General Notes" below for features present in Git but not in Darcs.

General Settings

Just like Darcs, Git has global and per-repository configuration options. To globally set your committer name and email use

git config --global "Haskell Curry"
git config --global


darcs init

git init

darcs get

git clone <repo-url> [<local-name>]

Possible repo URLs look like this:

git clone  # via HTTP (slowest)
git clone git://   # git's protocol (fast, read-only)
git clone [username@]  # via SSH

darcs add

git add <dir-or-file>

darcs record

Git supports interactive recording very similar to darcs.

git add -p


git add -i

The main difference is that Git does not automatically commit the changes. You have to do that manually using

git commit [-m "commit message"]

If you do not supply a commit message, it will open your default editor. If you want to abort the commit, use an empty commit message.

To see what will be committed, use

git diff --cached

Tip: If you want to see the diff when you edit the commit message, use

git commit -v

darcs record -a

git commit -a

This will add and commit all (not ignored) files. It will not add newly created files. (To do this call git add . before in the repo root directory.)

darcs changes

git log
git log <file-or-directory>

darcs changes --last <N>

git log -n <N>

darcs changes --summary

git log --stat

darcs changes --match

git log --grep="something"

(the =-sign is important)

Other useful variants

git log -p

Shows the patch for each commit.

git grep <text>

Look for something anywhere in the repository's history (tag names, commit messages, file contents).

git show <commit-id>

Show the changes by the given patch

More examples.

git log v2.5..v2.6            # commits between v2.5 and v2.6
git log v2.5..                # commits since v2.5
git log --since="2 weeks ago" # commits from the last 2 weeks
git log v2.5.. Makefile       # commits since v2.5 which modify
                              # Makefile

See git log --help for a lot of extra options, to refine the output.

darcs tag

git tag <tagname>

This will fail if the tag already exists. If you want to move an existing tag use git tag -f <tagname>, but never move a tag in a public repo/branch. Use this only on local branches, and only if the tag exists nowhere else. git tag --help contains a discussion of this.

darcs whatsnew

git status

darcs diff

git diff
git diff <commit1>..<commit2>  # show diff between two commits

darcs revert

git reset --hard

Note: git reset only resets the staged files, i.e., the things added with git add.

darcs unrecord


git reset --soft HEAD^

darcs amend-record

If the change to be amended is the latest commit

git commit --amend

TODO describe workflow if amended patch is not the current HEAD.

TODO add note for merge commits

darcs rollback

git revert <commit-id>

Working directory must be clean. (You can use git stash to save local changes).

darcs annotate

git blame

General Notes

The Index

Local Branches


git branch
git branch <name>
git branch -b <name>
git checkout
git branch -d <name>
git branch -D <name>
git stash
git show-branch
git pull
git fetch
git merge

Suggested Workflow


  • feature branches
  • git rerere