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:

  • How do I revert a pushed commit back to being unstaged?
  • How to remove all occurences of a file in index, from all git commits
  • How to edit log message already committed in Subversion?
  • Referring to the previous/next commit in git?
  • How do we verify commit messages for a push?
  • git fatal:No tags can describe <sha1 number>
  • 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 you use Source Control without IDE integration?
  • Is it possible to cherry-pick a commit from another repository without cloning the entire repository?
  • How does 'git log --graph' or 'hg graphlog' work?
  • I commit three times. How can I delete the second commit only?
  • How to commit my current changes to a different branch in git
  • How to list stats of resolved conflicts in a merge commit?
  • 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.

    Example:

    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"
    

    Update:

    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.