• Skip to main content
  • Skip to primary sidebar

Code Inherit

Simple Programming Code Examples

How to delete git branch and git hub branch ?

15th January 2024 by Site Admin Leave a Comment

To delete a branch in Git, you can use the following steps:

Deleting Locally:

  1. Open your terminal or command prompt.
  2. Navigate to your Git repository using the cd command:

cd /path/to/your/repository

Delete the branch locally using the following command:

git branch -d branch-name

Replace branch-name with the name of the branch you want to delete. If the branch has unmerged changes, you might need to use -D instead of -d to force the deletion:

git branch -D branch-name

Deleting Remotely (GitHub, GitLab, Bitbucket, etc.):

If you want to delete the branch on a remote repository (e.g., GitHub), you can use the following steps:

  1. Open your terminal.
  2. Use the following command to delete the remote branch:

git push origin –delete branch-name

Replace branch-name with the name of the branch you want to delete.

Deleting Locally and Remotely in One Command:

If you want to delete both the local and remote branches in one command, you can use:

git push origin –delete branch-name
git branch -d branch-name

Again, replace branch-name with the name of the branch you want to delete.

Make sure to be cautious when deleting branches, especially if they contain unmerged changes. Always double-check that you are deleting the correct branch.

Filed Under: Uncategorised

Reader Interactions

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

Primary Sidebar

Recent Posts

  • Bijoy Converter
  • How to amend previous commit with current changes in git and github?
  • How to install PHP 8.1 alongside PHP 7.4 using HomeBrew in MacOs?
  • Create a shell script to switch 7.4 to 8.1 and vice versa
  • How to reflect PHP8.1 to Apache in MacOS?

Recent Comments

    Archives

    • October 2025
    • September 2024
    • January 2024
    • July 2023
    • October 2021
    • September 2021
    • February 2021
    • January 2021
    • October 2020
    • September 2020
    • August 2020
    • May 2020
    • March 2020
    • February 2020
    • January 2020
    • November 2019
    • May 2019

    Categories

    • Couchbase
    • Cron Job
    • dhis2
    • Linux, MySQL
    • MySQL
    • Oracle
    • Oracle Client
    • PHP
    • SSL
    • Subdomain
    • Uncategorised
    • Wordpress
    • WP
    • Zip

    Meta

    • Log in
    • Entries feed
    • Comments feed
    • WordPress.org

    Copyright © 2025 · Genesis Sample on Genesis Framework · WordPress · Log in