Remove a local branch of the GitHub
How to remove a local branch of the GitHub
In this blog post, we will learn how to remove a local branch of the GitHub repository. To delete a local branch from Github one must execute the following code:
$ git branch -d <branch_name>
$ git branch -D <branch_name>
- The -d option is a shortcut for —delete, which only removes a branch if its upstream branch has fully merged it.
- The —delete —force option, which is sometimes known as the -D option, deletes the branch “regardless of its merged status.” (Refer to man git-branch)
- Git branch -d (delete) has learned to respect the -f (force) parameter as of Git version 2.3.
- If you try to delete the branch that is now chosen, you will get an error.
To delete a remote branch from Github one needs to follow the following commands:
$ git push <remote_name> --delete <branch_name>
another command for doing the same is:
$ git push <remote_name> :<branch_name>
function “to delete a remote branch or a tag” was added in Git version 1.5.0.
With Git version 2.8.0 and later, git push can also be used as an alias for —delete. Therefore, whether you should use the simpler or more complex syntax will depend on the version of Git you have installed. These are all the tricks one can apply to delete the local branch in a GitHub repository.
Also Read: Prediction using Logistic Regression in python
Pingback: What is Tab Error and their Solutions - Study Experts