Sourcetree git flow完成开发分支的功能,但开发分支受到保护

发布于 2025-01-20 20:52:00 字数 562 浏览 1 评论 0 原文

我犯了一个错误。 在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:
enter image description here

Error while pushing:
enter image description here

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

一生独一 2025-01-27 20:52:01

我的理解是,您将功能分支合并到本地 dev 中,但您对此感到遗憾,并希望在服务器端执行合并(通过拉取请求)。没问题!

  1. 从“Fix”提交创建一个新的功能分支并推送它(并在 GitHub 上请求拉取请求)。

  2. 然后将本地 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!

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

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文