course
Git Delete Branch: How to Remove Local and Remote Branches
This guide explains how to delete branches in Git—locally and remotely—while following best practices to avoid accidental data loss.
Mar 12, 2025 · 15 min read
Learn Git Fundamentals Today
For beginners: Master version control using Git.
Learn Git Fundamentals Today
For beginners: Master version control using Git.
Can deleting a branch in Git affect my production code?
How do I prevent my team from accidentally deleting important branches?
Is there a way to track who deleted a remote Git branch?
How do I recover a deleted Git branch if I closed my terminal?
What’s the difference between `git branch -d` and `git branch -D` in real-world use?
Topics
Learn more about Git with these courses!
2 hr
16.3K
course
Intermediate Git
2 hr
6.3K
course
Intermediate GitHub Concepts
3 hr
2.7K
See More
RelatedSee MoreSee More
tutorial
Git Rename Branch: How to Rename Local or Remote Branch
Learn how to rename local and remote Git branches using either the terminal or the graphical user interface (GUI) of popular clients like GitHub.
François Aubry
5 min
tutorial
Git Checkout Remote Branch: Step-by-Step Guide
To git checkout a remote branch, you first need to fetch the latest changes from the remote repository, then you can checkout the remote branch locally using its full name (e.g., origin/branch-name).
François Aubry
4 min
tutorial
Git Pull Force: How to Overwrite a Local Branch With Remote
Learn why git pull --force isn’t the best way to overwrite a local branch with the remote version, and discover the proper method using git fetch and git reset.
François Aubry
tutorial
Git Switch Branch: A Guide With Practical Examples
Learn how to switch a branch in Git using git switch and understand the differences between git switch and git checkout.
François Aubry
8 min
tutorial
Git Pull: Keeping Your Local Repository Up to Date
The git pull command retrieves updates from a remote repository and merges them into your current branch. Keep reading to learn to avoid unnecessary merge conflicts.
Oluseye Jeremiah
8 min
tutorial
Git Prune: What Is Git Pruning and How to Use Git Prune
Git prune is a Git command that removes objects from the repository that are no longer reachable from any commit or branch, helping to free up disk space.
François Aubry
5 min