简体   繁体   中英

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)?

:(

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

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!

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM