Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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:

  1. How can I set the fork repo so that pull requests default to fork>master branch?
  2. How can I convert the forked repo to a "normal" repo, "forgetting" the original repo?
like image 574
Jonathan Avatar asked Jun 10 '18 13:06

Jonathan


1 Answers

The purpose of git fork repo is contribute to the upstream (original) repo. So the forked repo and the original repo always has relations between them.

And if you want to create a new repo (without any relation with the original repo), but with and same code and branches as the original repo, then you should create an empty git repo and push all the branches from the original repo into the new created repo instead of forking the original repo. Detail steps as below:

1. Create a new git repo in your VSTS project

In VSTS web page, create a new git repo. Detail steps, you can refer the document create a repo using the web portal.

Assume the git repo name is myrepo and the URL is https://account.visualstudio.com/project/_git/myrepo.

2. Clone and checkout all the branches from the original repo locally

If you have not cloned the original git repo, you can clone the original git repo by:

git clone <original git repo URL>

Then checkout all the remote branches locally by the command:

git checkout <remote branchname>

3. Push all the branches from local original repo to the new created repo

In the local original git repo, add remote for the new created git repo and push all the branches to the new created git repo. Detail commands as below:

#In the local original repo
git remote add myrepo https://account.visualstudio.com/project/_git/myrepo
git push myrepo --all

Now all the branches are pushed into the new created git repo and it's separate with the original git repo.

like image 80
Marina Liu Avatar answered Oct 27 '22 16:10

Marina Liu