How to delete a loc…
 
Notifications
Clear all

How to delete a local branch in git?

2 Posts
3 Users
0 Likes
344 Views
0
Topic starter

How to delete a local branch in git using command line, not any external tools.

2 Answers
0
  1. Delete a local branch: git branch -d/-D <branchName> (the -D option is for force deletion)
  2. Delete a remote branch: git push origin -d <branchName> or git push origin :<branchName>
0

To delete a local branch in Git using the command line, you can use the following command:

Replace branch-name with the name of the branch you want to delete. Make sure you are in the repository’s root directory when running this command.

If the branch has not been merged into the current branch, Git will show a warning. If you want to force-delete the branch without considering its merge status, you can use the -D option instead:

git branch -d branch-name
usechatgpt init success
Share: