2

I created a branch and committed a changeset as a child of a child of my main branch. I actually meant to shelve the changes and create a new branch off of my main branch. How can I revert and/or make the branch a direct child of my main branch?

I have a hunch that I will need to revert or do a subtractive merge.

1 Answers1

4

For PlasticSCM, the idea would similar to what is described below for Git:

  • having a branch referring to your current commit
  • reset the branch to the last correct commit
  • use the switchbranchbase command mention for PlasticSCM4 or the simple merge mention in this thread.

    • In PlasticSCM 3.0 to perform a rebase the steps were: Change branch base, update, merge.
    • In PlasticSCM 4.0 is easier, just perform the merge from the branch you want to rebase.

Original answer in git:

If you have:

 x--x--x--x                 main
           \
            y--y--y         child
                   \
                    z--z    mybranch

You can do a:

git rebase --onto main child mybranch

That would give you:

            z'--z'          mybranch
           /
 x--x--x--x                 main
           \
            y--y--y         child

If you didn't want to rebase all of my branch, then a simple:

git checkout mybranch
git branch -b mynewbranch
git reset --hard z          # reset mybranch HEAD to the last commit before your new commit
git rebase --onto main mybranch mynewbranch

For a single commit, you could also use git cherry-pick, but I always prefer git rebase.

Community
  • 1
  • 1
VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250
  • Gosh, this is a great answer and I apologize for not making it clearer that I needed an answer specific to PlasticSCM. Just updated the title to reflect that. Regardless, I still appreciate the excellent explanation (I do use Git a bunch). –  Oct 08 '13 at 06:50
  • 1
    @MicahDelaneBolen as in http://www.plasticscm.net/index.php?/topic/671-plastic-scm-4-rebase/ ? – VonC Oct 08 '13 at 06:51
  • ...yes. I guess I should accept your answer since `rebase` is the key ingredient in either scenario. Again, my apologies. –  Oct 08 '13 at 06:54
  • @MicahDelaneBolen I have added command/links specifc for PlasticSCM. – VonC Oct 08 '13 at 06:59
  • That's the reason I love Plastic SCM so much! Great answer!! – cidico Oct 09 '13 at 16:50
  • @tuket That might have changed since my 2013 answer indeed. – VonC May 04 '20 at 15:39