Home > Enterprise >  Sourcetree git flow finish feature to develop branch but develop branch is protected
Sourcetree git flow finish feature to develop branch but develop branch is protected

Time:04-12

I made a mistake. In Sourcetree I created a new feature branch starting from develop and made some changes. Afterwards I wanted to finish the feature and delete the feature branch. Sadly I forgot that the develop branch is protected and needs at least one review before being allowed to commit to it. Also I don't have the rights to circumvent this.

Now my feature branch is deleted and my changes can't be pushed.

How can I revert my mistake and e.g. get the feature branch back (or creating a new one) and creating a pull request instead of just finishing it instead?

The (anonymized) graph looks something like this: enter image description here

Error while pushing: enter image description here

CodePudding user response:

My understanding is that you merged your feature branch into dev locally but you regret this and wish to perform the merge at the server side instead (by way of a pull request). No problem!

  1. Create a new feature branch from the "Fix" commit and push it (and ask for pull request at GitHub).

  2. Then hard reset your local dev to the commit before the merge (not shown in your screenshot), thus undoing the unwanted local merge.

    Or, even better, delete your local dev entirely! It serves no purpose, as you can never merge to it, and it leads you into errors like this one. To create a new branch in future, just fetch and then branch from origin/dev. That's what the professionals do!

(Both those things are quite easily done in Sourcetree, though personally I would use the command line.)

  • Related