Search code examples
gitgithubrebase

Git Flow, checked out branch from master, rebase to develop


Im working with git flow and I have a master and develop branch. Sometimes people dont checkout from master but develop. When the PR is submitted in GitHub it points to master. Can I somehow change that the branch is based of of develop?

I found git rebase but dont exactly know if its what im searching for.


Solution

  • Yes, that is one of the things rebase can do for you. Assuming the incorrectly based branch is called foo and you want to change the base from master to develop (the direction you want wasn't entirely clear to me from your question), this is how to do it:

    git checkout foo
    git rebase --onto develop master
    

    The manpage for git rebase has a lot more details about how rebase works and what it does, as does the Git book.

    The most important thing to know here is that if master and develop are sufficiently different, the rebase operation might run into conflicts that you will have to fix manually - for every single commit on foo in the worst case. Rebase conflicts can be a little counter-intuitive, so don't rush through it. :)