Git delete remote & local branch
Git Delete a remote & local branch command. You can easily delete the branch in this way.
Executive Summary
$ git push <remote_name> -d <branchname>
$ git branch -d <branchname>
STEP#01
TITLE: GET ALL BRANCH (LOCAL + REMOTE)
$ git branch -a
- *master
- test
- remote/origin/master
- remote/origin/test
STEP#02
TITLE: GET ONLY LOCAL BRANCH
$ git branch
- *master
- test
STEP#03
TITLE: GET ONLY REMOTE BRANCH
$ git branch -r
- remote/origin/master
- remote/origin/test
STEP#04
TITLE: DELETE LOCAL BRANCH
$ git branch -d <branch_name>
$ git branch -D <branch_name>
$ git branch -d test
- Deleted branch test (was e5of334).
Note:
- -d, –delete
Delete a branch. The branch must be fully merged in its upstream branch, or in HEAD if no upstream was set with –track or
–set-upstream-to.- -D
Shortcut for –delete –force. [Source:man git-branch
]
STEP#05
TITLE: DELETE REMOTE BRANCH
(OPTION 1)
$ git push <remote_name> -d <branch_name>
$ git push origin -d test
Username for 'https://github.com': <username>
Password for 'https://[email protected]': <password>
To https://github.com/username/repo.git
- [deleted] test
(OPTION 2, MOST EASIEST WAY
$ git push <remote_name> :<branch_name>
$ git push origin :test
Username for 'https://github.com': <username>
Password for 'https://[email protected]': <password>
To https://github.com/username/repo.git
- [deleted] test
Note: In most of the cases <remote_name> will be origin
Solved my Problem….
It’s really helpful