Search code examples
tortoisegit

Can you move a branch so that it is under another parent?


I have a master repository.

Yesterday I started my first branch and called it ImportPTS.

But then I found this tutorial:

http://nvie.com/posts/a-successful-git-branching-model/

I would like to adopt it. Thus, I need to make a new branch from master called develop.

Then, ImportPTS needs to be under that branch instead. Eventually I will have other branches under develop until I am ready to merge it as a feature branch.

But is it possible? Can I move the branch as described?

Clarification

Change from:

master
    ImportPTS

To

master
    develop
        ImportPTS

Solution

  • What you want to do sounds like a "rebase" task - rewriting history of commits and, thus, has be used with caution.

    In order to put the ImportPTS branch on top of develop, open the log dialog and switch to the ImportPTS branch. Then open the context menu on the latest commit of the develop branch and select "Rebase onto..." there.

    Now a new dialog opens, where you can see all commits you want to "rebase" or put onto your develop branch. If you don't want to re-order, combine, skip or modify commits, just leave them as they are and click on "Start".

    After that, your ImportPTS branch should be on top of the develop branch.

    Also see https://tortoisegit.org/docs/tortoisegit/tgit-dug-rebase.html.