Reputation: 83
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)?
:(
Upvotes: 1
Views: 1846
Reputation: 83
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!
Upvotes: 5
Reputation: 30212
Rebase will work fine, but you have to tell it also which revisions to skip from rebase. If the branch is gone, use the last revision ID of the base branch below your branch (which can be seen with a simple git log
):
git rebase --onto develop id-last-revision-of-A feature/B
Upvotes: 1