Delete a git branch local and remote
November 10th, 2018
Comments off
This is a continuation of my earlier post about pruning deleted branches
To delete a local branch
|
1 |
git branch -d <branch_name> |
or you can ‘force’ a delete if you have uncommitted changes
The -D is the same as --delete --force
|
1 |
git branch -D <branch_name> |
To delete the branch remotely, simply do …
|
1 |
git push --delete <remote_name> <branch_name> |
You can also do it like that if you prefer.
|
1 |
git push <remote_name> --delete <branch_name> |
Again, you can use -d.
If you want to delete a remote and local branch, it is easier to first delete the remote branch and then the local branch.
You can then go ahead and prune all the branches.
|
1 |
git fetch --all --prune |
Recent Comments