Undo an accidental hg strip?

后端 未结 3 932
佛祖请我去吃肉
佛祖请我去吃肉 2020-12-06 09:46

I have accidentally run hg strip, and deleted a stack of commits. I have not done anything in the repo since. Is there a way for me to bring back this stack of commits, to u

3条回答
  •  孤城傲影
    2020-12-06 10:25

    It is possible to hg pull from a strip backup file as an alternative to using hg unbundle.

    As noted in a comment on another answer to this question, hg unbundle has fewer options and only works with bundles, but can unbundle more than one bundle at a time. Whereas hg pull can pull from a single source (share/web/bundle) and has other options.

    Here's an example of using hg pull based on an external post by Isaac Jurado:

    Usually the backup is placed in REPO/.hg/strip-backup/. See the example below:

     $ hg glog
     @  changeset:   2:d9f98bd00d5b tip
     |               three
     o  changeset:   1:e1634a4bde50
     |               two
     o  changeset:   0:eb14457d75fa
                     one
     $ hg strip 1
     1 files updated, 0 files merged, 0 files removed, 0 files unresolved
    
     saved backup bundle to
     /Users/hchapman/ttt/.hg/strip-backup/e1634a4bde50-backup.hg
    

    And then, what one would do to recover those changesets would be:

    $ hg pull $(hg root)/.hg/strip-backup/e1634a4bde50-backup.hg
    

提交回复
热议问题