

Most developers manage local branches through the CLI and push their code to GitHub (or a similar platform) if they want web-based management features. The exception is if you run some type of local Git web interface that supports branch deletion, but this is rare. This command deletes a local branch with the name branchname.īecause Git doesn't provide a web interface, deleting local branches through the command line is typically the only way to remove a local branch. You can do it on the CLI with a command such as: git branch -d branchname Deleting Local Branches with Gitĭeleting local branches is simpler. While this CLI approach works for removing remote branches, the best way to remove a branch hosted on GitHub is to use the web interface. Unfortunately, however, because git branch doesn't support deletion of remote branches, this is how you have to manage remote branch deletion with Git. This syntax may seem confusing because it uses the git push command instead of git branch. For example: git push origin -delete :somebranch Then, you can use the git push : command to delete a branch. You must first set up Git on your computer and integrate it with GitHub by following the steps in the GitHub documentation. If you prefer to work from the CLI, you can delete GitHub branches that way, too. To delete a branch, click the trashcan icon next to its name.You'll see a list of branches in the repository. Start by navigating to the main page of the repository that hosts the branch you want to delete.Steps for Deleting Remote Branches on GitHubĭeleting remote branches that are hosted on GitHub is easy, as long as you are managing them through your GitHub account. Fortunately, it's possible to recover deleted branches, as we explain later in this article. That said, there are situations where you may end up deciding after the fact that you didn't actually want to delete a branch. If you decide to delete a branch, it's probably because you are done using it and you no longer want it to be a distraction when you are working within a repository. Usually, this is what you want to happen.
#DELETE MASTER GIT HOW TO#
Related: How to Get the Newest Google Snake Mods on GitHub You'll no longer be able to track or view the branch, and the branch will be removed from your remote repository. When you delete a remote branch (or a local branch, for that matter), the branch disappears from your GitHub workflow.

What Happens When You Delete a Remote Branch on GitHub? Indeed, in many cases branches that end up on GitHub originate as local branches that a developer builds on his or her own computer, and then later pushes to GitHub.

All branches that exist on GitHub itself are remote branches from the perspective of a local machine, although again, you may have to work with local branches in the context of using GitHub. Remote branches are branches of code hosted on a remote machine - such as GitHub servers. For example, you may be working with code in a local branch that you push to GitHub, and decide to delete the local branch after it has been merged into a remote branch. These branches aren't actually hosted on GitHub, but you might still want to delete them as part of a GitHub-centered workflow. Local branches are branches of code stored on a developer's local machine. There are two types of branches you can work with on GitHub: local and remote branches. Developers might also choose to delete a branch if they've decided to abandon the changes contained in it because, for example, the changes are buggy or they address application features that the developers decided not to add. Instead, they routinely delete branches once they've merged them into other branches. That said, most developers don't want to retain every GitHub branch that they create for an indefinite period of time. Related: How to Use GitHub Personal Access Tokens In addition, branches can be "merged" in order to integrate multiple sets of changes. By treating each set of changes as a distinct branch, it's easy to decide which changes to keep and which to discard. A branch is a set of changes that a developer has made to code. Like other Git repository hosting platforms (such as GitLab), GitHub uses branches to help developers manage source code. What Is a GitHub Branch, and Why Would You Delete It? We'll also explain how to delete multiple branches at once, how you can undelete branches, and how to delete an entire repository if you find yourself wanting to do so. Keep reading for a breakdown of how branch deletion works in GitHub and how to delete remote branches under various circumstances. However, it varies depending on which interface you're working with and whether you're dealing with a local or a remote branch. The process for deleting GitHub branches is pretty straightforward.
