Is there any way to delete local commits in Mercurial?

后端 未结 10 1056
小鲜肉
小鲜肉 2020-11-28 19:11

So I keep making a silly mistake in Mercurial. Often times, I\'ll start work without doing an \"hg pull\" and an \"hg update.\" When I try to push my changes, I get an err

10条回答
  •  被撕碎了的回忆
    2020-11-28 19:59

    In addition to Samaursa's excelent answer, you can use the evolve extension's prune as a safe and recoverable version of strip that will allow you to go back in case you do anything wrong.

    I have these alias on my .hgrc:

     # Prunes all draft changesets on the current repository
     reset-tree = prune -r "outgoing() and not obsolete()"
     # *STRIPS* all draft changesets on current repository. This deletes history.
     force-reset-tree = strip 'roots(outgoing())'
    

    Note that prune also has --keep, just like strip, to keep the working directory intact allowing you to recommit the files.

提交回复
热议问题