Perform an empty commit with mercurial

With with Mercurial queues extension, I can make an empty commit with some commit message like so:

hg qnew patch_name -m "message"

Is there a way to do this without Mercurial queues? I tried simply:

  • Git is failing to Stage, or commit with SourceTree in a Windows network environment
  • How to git clone 'git' metadata only
  • SVN hooks not working
  • GitHub commit with “invalid email”
  • How can I get/list/see all the descendants of a commit with git (or gitk)?
  • How do I correct “Commit Failed. File xxx is out of date. xxx path not found.”
  • hg commit -m "message"

    but hg just says “nothing changed” and doesn’t do the commit, and I don’t see any “force” option that would override that.

    If you’re wondering about my motivation for doing this: we have testing infrastructure where you push to a special repository and it will trigger automated tests to run. You need to put a special string into the commit message of the tipmost commit that says which tests to run. Obviously, I don’t want this string in there when I push to the actual repository. Rather than amending the commit twice (once to add the special string, and a second time to remove it), I would find it cleaner to just add an empty commit, and then roll it back — and I can do this with mq, but I’d like to find a way to do it without mq.

  • How do I revert a pushed commit back to being unstaged?
  • Git push vs. git push heroku master
  • Git : Head commit in remote repository is crap - how exactly should I go about replacing it?
  • How to import a Bitbucket project into Github on Windows
  • Editing the git commit message in GitHub
  • Mercurial: How to deal with one branch that has two heads
  • 2 Solutions collect form web for “Perform an empty commit with mercurial”

    You can use hg commit --amend to create empty commits.

    Just create an arbitrary commit and backout the change. Afterwards fold both commits together.


    touch tmp                               # create dummy file
    hg add tmp                              # add file and...
    hg commit -m "tmp"                      # ... commit
    hg rm tmp                               # remove the file again and ...
    hg commit --amend -m "empty commit"     # ... commit

    You can make commit that’s closing the branch:

    hg commit --close-branch -m "message"


    You can close branch once, but it can be reopened with another commit. Simplest way to reopen branch without changing files is to tag some revision. So you can use hg commit --close-branch for empty commit and then hg tag for reopening.

    Update v2

    Actually you can create new empty commits with just hg tag command. It has -m parameter for setting a commit message. If you don’t really care about correctness of this tags, you can use just one tag name by calling hg tag with -f parameter:

    hg tag t1 -f -m "message"
    Git Baby is a git and github fan, let's start git clone.