Perform an empty commit with mercurial

后端 未结 3 1186
灰色年华
灰色年华 2021-01-04 02:29

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

hg qnew patch_name -m \"message\"

Is the

相关标签:
3条回答
  • 2021-01-04 03:09

    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
    
    0 讨论(0)
  • 2021-01-04 03:19

    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"
    
    0 讨论(0)
  • 2021-01-04 03:29

    You can now create empty commits by just doing hg ci -m "empty commit"

    e.g.

    hg branch my-next-branch
    hg ci -m "empty commit"
    

    Will create a my-next-branch with a single empty commit that you can push to the remote repo.

    0 讨论(0)
提交回复
热议问题