Been banging my head around on this one. All I'm trying to do is set the a branch on the hosted TFS git repo to be default via the command line.
From what I can tell there's no obvious way to do this directly against the hosted repo, however in my case, since I'll end of scripting this, I have no objection in doing it locally and pushing it to the origin.
I tried things like:
git branch --set-upstream-to origin/master
to set master as the default branch within the hosted repo to no avail, so am unsure if I got the wrong end of the stick here.
I'm still a git toddler here so be easy on me if I missed something blindingly obvious!
Under your project repo, select Branches. On the Branches page, select More options next to the new default branch you want, and choose Set as default branch. After you set the new default branch, you can delete the previous default if you want.
Change the default branch name for a projectIn the left navigation menu, go to Settings > Repository. Expand Default branch, and select a new default branch. Optional. Select the Auto-close referenced issues on default branch checkbox to close issues when a merge request uses a closing pattern.
The default branch is also the initial branch that Git checks out locally when someone clones the repository. Unless you specify a different branch, the default branch in a repository is the base branch for new pull requests and code commits. By default, GitHub names the default branch main in any new repository.
There isn't any way to set a Default branch on a TFS Hosted Repository with REST API or command line for now.
Check the Git command reference, the Git command line for setting a default branch in your Team Services/TFS repo is still on the web access (Select the settings icon on the web, then select the Version Control tab. Select your Git repository, then select the ... next to the branch name and choose Set as default branch).
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With