• Skip to primary navigation
  • Skip to main content
  • Skip to primary sidebar
  • Skip to footer navigation

The Geek Diary

  • OS
    • Linux
    • CentOS/RHEL
    • VCS
  • Interview Questions
  • Database
    • MariaDB
  • DevOps
    • Docker
    • Shell Scripting
  • Big Data
    • Hadoop
    • Cloudera
    • Hortonworks HDP

git delete-branch: Delete local and remote Git branches

by admin

The “git delete-branch” command is a utility provided by the “git-extras” extension that allows you to delete local and remote Git branches with ease. This command simplifies the process of removing branches from your repository, saving you from having to execute multiple Git commands.

When you run the “git delete-branch” command, you can specify the branch you want to delete. It performs the following actions:

  • Delete Local Branch: The command removes the specified branch from your local repository. This means that the branch will no longer be available on your local machine, and you won’t be able to perform any local operations on that branch.
  • Delete Remote Branch: By default, the command also deletes the corresponding branch on the remote repository. This is particularly useful when you want to remove a branch that has already been pushed to a remote repository, ensuring that the branch is removed from both your local and remote repositories.
  • Checked Out Branch: If you attempt to delete the branch that you currently have checked out (the branch you’re currently working on), the command only deletes the remote branch. This prevents accidental deletion of the branch you’re actively working on, as it would cause disruption to your workflow.

Using the “git delete-branch” command provides a convenient way to manage your branches by quickly removing branches that are no longer needed, both locally and remotely. It simplifies the branch deletion process and helps keep your repository clean and organized.

It’s worth noting that the “git-extras” extension is not a built-in part of Git, but rather a collection of additional commands and features provided by a third-party extension. To use the “git delete-branch” command, you need to install the “git-extras” extension, which can be found and installed from the official “git-extras” repository.

git delete-branch Command Examples

1. Delete a local and remote Git branch:

# git delete-branch branch_name

2. Delete multiple local and remote Git branches:

# git delete-branch branch_name1 branch_name2 ...

Filed Under: Linux

Some more articles you might also be interested in …

  1. “git send-email” Command Examples
  2. How to Compress and Extract Files and Directories in Linux Using gzip and bzip2
  3. How to use command line shell functions in Linux
  4. cmatrix: Shows a scrolling Matrix like screen in the terminal
  5. Testing Kdump Functionality in CentOS/RHEL 9
  6. chkconfig: command not found
  7. gixy Command Examples
  8. gvpack Command Examples
  9. at Command Examples in Linux
  10. RDEPENDS V/s DEPENDS in Yocto

You May Also Like

Primary Sidebar

Recent Posts

  • Vanilla OS 2 Released: A New Era for Linux Enthusiasts
  • mk Command Examples
  • mixxx Command Examples
  • mix Command Examples

© 2025 · The Geek Diary

  • Archives
  • Contact Us
  • Copyright