git - Setting a forked repo's pull request default branch
问题描述
Background: I have a project "original" in a VSTS-hosted git repo and wanted to create a similar project, so I forked the repo. I have no intention of merging from the fork to the original repo - they'll be 2 separate projects. The forked repo's master branch policy that requires pull requests, no direct pushes.
Now, whenever I create such a pull request, the default target is not fork>master but original>master. I always manually change it to fork>master, but it's annoying...
Questions:
- How can I set the fork repo so that pull requests default to fork>master branch?
- How can I convert the forked repo to a "normal" repo, "forgetting" the original repo?
解决方案
git fork repo 的目的是为上游(原始)repo 做出贡献。所以分叉回购和原始回购之间总是有关系。
如果你想创建一个新的 repo(与原始 repo 没有任何关系),但代码和分支与原始 repo 相同,那么你应该创建一个空的 git repo 并将原始 repo 中的所有分支推送到新创建的存储库,而不是分叉原始存储库。详细步骤如下:
1. 在你的 VSTS 项目中创建一个新的 git repo
在 VSTS 网页中,创建一个新的 git repo。详细步骤,您可以参考使用门户网站创建 repo的文档。
假设 git repo 名称是 myrepo 并且 URL 是https://account.visualstudio.com/project/_git/myrepo
.
2. 从本地原始仓库中克隆并签出所有分支
如果您还没有克隆原始 git repo,您可以通过以下方式克隆原始 git repo:
git clone <original git repo URL>
然后通过以下命令在本地签出所有远程分支:
git checkout <remote branchname>
3.将本地原始repo的所有分支推送到新创建的repo
在本地原始git repo中,为新创建的git repo添加remote,并将所有分支推送到新创建的git repo。详细命令如下:
#In the local original repo
git remote add myrepo https://account.visualstudio.com/project/_git/myrepo
git push myrepo --all
现在所有分支都被推送到新创建的 git repo 中,并且与原始 git repo 分开。
推荐阅读
- javascript - Discord Bot 初始化失败
- google-sheets - 当响应应该是谷歌表格中单元格值的总和时,如何解决“查询完成时输出为空”?
- android - 内容提供者仍然是合适的沟通方式吗?
- flutter - 来自flutter的dart-sdk问题
- bash - 您可以在查找中指定通配符表达式后的深度吗?
- reactjs - 如何在自定义 Typescript 库和主机上同时使用 i18next?
- javascript - 为什么我的按钮打印在背景下?
- sql - 如何根据来自不同表的值填充表
- scala - 在 scala/akka 的计算之间检查参与者的消息查询
- expression - [[:digit:]] 和 [0-9] 有什么区别?