Search code examples
gitatlassian-sourcetreegit-flow

Git Flow Feature to branch Develop when Feature it was based off doesn't exist anymore


I got myself into a small bit of a pickle.

I accidentally based a feature (let's call it A) off another feature (let's call it B) instead of the develop branch. In the meantime, feature A was completed and merged to develop.

Now I want to finish feature B, but I'm getting the following error on Sourctree

Fatal: The base 'feature/A' doesn't exists locally or is not a branch. Can't finish the feature branch 'feature/B'.

I've tried: git rebase --onto develop feature/B

But this only removed the changes from B and pushed develop on the branch, I'm lucky my remote picked it up and I was able to pull/sync the changes I had on remote to restore what was on B.

Is there any way I could come back from this? To somehow change the reference that B was based on A to say that B is based off develop (that already contains A)?

:(


Solution

  • In Sourcetree, if you navigate to Settings -> Edit Config File (open in Notepad), you can change:

    [gitflow "branch.feature/B"]
        base = branch.feature/A
    

    to:

    [gitflow "branch.feature/B"]
        base = develop
    

    Which will then allow you to finish the feature on branch develop (just get ready for any potential conflicts. In my case I had none since feature A was already in the develop branch)

    Just make sure you don't mistakenly base a feature off another feature like I did!