How do I put a bunch of uncommitted changes aside while working on something else

前端 未结 4 1074
夕颜
夕颜 2021-01-30 02:49

If I have a bunch of uncommitted changes and want to set it aside while working on something else instead, and then later (f.i. after several days) come back to it and proceed w

4条回答
  •  天命终不由人
    2021-01-30 03:39

    Personally, I don't like any of the answers posted so far:

    1. I don't like clone branching because I like each project to have only one directory. Working on different directories at the same time completly messes the history of recent files of my editors. I always end up changing the wrong file. So I don't do that anymore.
    2. I use shelve for quick fixes (just to move my uncommited changes to another branch, if I realize I'm at the wrong one). You are talking about days, no way I'd shelve something for days.
    3. I think mq is too complicated for such an ordinary sittuation

    I think the best way is to simply commit your changes, than you go back to the changeset before you start these changes and work from there. There are some minor issues, let me illustrate:

    Let's say you have the changeset A. Than you start your changes. At this point you want set it aside for a while. First of all, commit your work:

    hg ci -m "Working on new stuff"
    

    If you want, you can add a bookmark to make it easier to come back later. I always create bookmarks to my anonymous branches.

    hg bookmark new-stuff
    

    Go back to the changeset before these modifications

    hg update A
    

    From here, you work and generate the changeset C. Now you have 2 heads (B and C), you'll be warned when you try to push. You can push only one branch by specifying the head of that branch:

    hg push -r C
    

    Or you can change the phase of the new-stuff branch to secret. Secret changesets won't be pushed.

    hg phase -r new-stuff --secret --force
    

提交回复
热议问题