Git
Git Tutorial for Beginners with Examples
Install Git
Add Local Project to Remote Git Repository
How to Clone a Project from a Remote Git Repository
Create a New Branch in Git
Switching Branches in Git
How to Push Code from Local to Remote Repository
Pushing a New Local Branch to a Remote Git Repository
Deleting a Git Branch Both Locally and Remotely
Restoring a Deleted Git Branch
Switching to a Different Branch Without Committing Changes in Local Git Repository
Git Stash Revert: How to Restore Stashed Changes in Git
Creating a Git Pull Request
Cancel a Git Pull Request
Tags in Git
Git Commands for Beginners
Generating a Personal Access Token on GitHub
Update the Local Branch with the Latest Code Changes from the Remote Branch
Compare Two different Git Branches in Visual Studio Code
Deleting a Git Branch Both Locally and Remotely
- Last updated Apr 25, 2024
To remove Git branches both from your local development environment and from the remote repository, do the following:
- Delete a Local Branch:
The git branch -d command is used to delete a local branch. In some cases, deleting of a branch may failed if the branch contains commits that have not been merged with any local or remote branch. If you want to delete such a branch forcefully then use -D flag. For example:
git branch -D branch_name
To delete a remote branch, you need to first delete it locally and then push the update using the following command:
git push -d origin branch_name
Replace 'branch_name' with the name of the branch you want to delete.