Редактиране

Споделяне чрез


Delete a Git branch

Azure DevOps Services | Azure DevOps Server 2022 - Azure DevOps Server 2019

Visual Studio 2019 | Visual Studio 2022

This article describes how to delete a Git branch by using two different methods: in Visual Studio and from the command line.

Note

Deleting a branch in your local repo doesn't remove the branch on the remote.

Prerequisites

Category Requirements
Project access Member of a project.
Permissions - View code in private projects: At least Basic access.
- Clone or contribute to code in private projects: Member of the Contributors security group or corresponding permissions in the project.
- Set branch or repository permissions: Manage permissions permissions for the branch or repository.
- Change default branch: Edit policies permissions for the repository.
- Import a repository: Member of the Project Administrators security group or Git project-level Create repository permission set to Allow. For more information, see Set Git repository permissions.
Services Repos enabled.
Tools Optional. Use az repos commands: Azure DevOps CLI.

Note

In public projects, users with Stakeholder access have full access to Azure Repos, including viewing, cloning, and contributing to code.

Category Requirements
Project access Member of a project.
Permissions - View code: At least Basic access.
- Clone or contribute to code: Member of the Contributors security group or corresponding permissions in the project.
Services Repos enabled.

Delete branch

  1. View your repo's branches by selecting Repos > Branches while viewing your repo on the web.

    Screenshot that shows how to access your branches.

  2. Select the More options button at the end of the row of the branch you want to delete.

    Screenshot that shows how to access the menu to delete a branch.

  3. In the options menu, select Delete branch.

  4. In the Delete branch dialog box, select Delete.

Next steps