Git delete branch locally and remotely12/11/2023 ![]() When deleting a branch both locally and remotely, it might be a good idea to use the following command on all other computers that might be working on the same repository and therefore might contain obsolete tracking data. Things To Keep In Mind When Deleting Branchesĭepending on the version of git you are using, you might have remote-tracking branches in addition to your local and remote branches. In most cases, this tends to be origin.įor example, if you're deleting a remote branch named fix/ui-nits on the remote origin, your command would be: $ git push origin -delete fix/ui-nits Here, is the name of your remote repository. If you have already pushed your git branch to remote servers, you will have to follow a different method to remove and permanently delete it from the cloud. This force deletes the branch irrespective of whether it has been merged or not. ![]() On the other hand, the -D option is shorthand for -delete -force. This command will only delete the branch if it has been merged and pushed to the remote origin. Here, The -d flag is a shorthand version for -delete. Once you're on a different branch, you can use one either – $ git branch -d For example, you could checkout to your master branch by using the following command: git checkout master. Git does now allow users to delete the branch that they are currently on. The first thing you need to do if you want to delete a local branch is to check out to a different branch (one that you do not wish to delete).
0 Comments
Leave a Reply.AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |