我犯了一个错误。
在Sourcetree中,我创建了一个新功能分支,从开发开始,并进行了一些更改。之后,我想完成该功能并删除功能分支。可悲的是,我忘记了开发分支受到保护,并且至少需要一份审查,然后才能允许进行审查。另外,我没有规避这一点的权利。
现在,我的功能分支已删除,无法推动我的更改。
如何恢复错误,例如将功能分支恢复(或创建新的分支)并创建拉动请求而不是仅仅完成它?
(匿名)图看起来像这样:
推动时错误:
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:
Error while pushing:
发布评论
评论(1)
我的理解是,您将功能分支合并到本地
dev
中,但您对此感到遗憾,并希望在服务器端执行合并(通过拉取请求)。没问题!从“Fix”提交创建一个新的功能分支并推送它(并在 GitHub 上请求拉取请求)。
然后将本地
dev
硬重置为合并之前的提交(屏幕截图中未显示),从而撤消不需要的本地合并。或者,更好的是,完全删除您的本地
dev
!它没有任何作用,因为你永远无法合并到它,并且它会导致你陷入像这样的错误。要将来创建新分支,只需从origin/dev
获取然后分支即可。这就是专业人士所做的!(这两件事在 Sourcetree 中都很容易完成,尽管我个人会使用命令行。)
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!Create a new feature branch from the "Fix" commit and push it (and ask for pull request at GitHub).
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 fromorigin/dev
. That's what the professionals do!(Both those things are quite easily done in Sourcetree, though personally I would use the command line.)