Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to delete a remote branch without deleting the local on git?

Tags:

git

Does git push origin :<branch> delete the local branch as well? I need to save my local changes but delete the remote branch, and I can't test out creating a new branch/pushing and deleting right now. If not, is there any other way to delete a remote branch but keep the local branch/changes in the branch?

like image 422
VMS Avatar asked Nov 07 '17 18:11

VMS


People also ask

How do I delete a remote git branch?

Steps to delete remote Git branchesIssue the git push origin –delete branch-name command, or use the vendor's online UI to perform a branch deletion. After the remote branch is deleted, then delete the remote tracking branch with the git fetch origin –prune command.

Does deleting a branch on Github delete it locally?

Deleting a branch LOCALLYThe -d option will delete the branch only if it has already been pushed and merged with the remote branch. Use -D instead if you want to force the branch to be deleted, even if it hasn't been pushed or merged yet. The branch is now deleted locally.

Does deleting local branch delete remote branch?

In Git, local and remote branches are separate objects. Deleting a local branch doesn't remove the remote branch.


1 Answers

No, it doesn't delete the local branch. Doing the command you stated does exactly what you want.

like image 177
jhpratt Avatar answered Sep 20 '22 20:09

jhpratt