I have a branch and a tag by the name 3.0.0
. Now how do i only delete the branch not the tag.
I tried
git push origin --delete 3.0.0 error: dst refspec 3.0.0 matches more than one.
To delete a remote branch, you can't use the git branch command. Instead, use the git push command with --delete flag, followed by the name of the branch you want to delete. You also need to specify the remote name ( origin in this case) after git push .
You should never name a tag and a branch the same name! It makes sense in a case like this to use naming conventions on the tags to keep from colliding on the branch names. Versus when we releasing code from the master branch. You can find the common parent in git using merge-base to do a Tag on code from the past.
The tag and commit would still exist if the branch is deleted. A branch is simply a way to track a collection of commits.
It is safe to delete your local branch after you pushed your changes to your own remote repository. The pull request is unrelated to this, because it is simply a request to the maintainers of the original repository to merge your changes back into their code base.
You can push the full branch refspec:
git push origin :refs/heads/3.0.0 # shorter: git push origin :heads/3.0.0
That would reference only a branch, not a tag (refs/tags/3.0.0
).
Here the refspec has no source in front of the ':
': that means HEAD
.:refs/heads/3.0.0
is HEAD:refs/heads/3.0.0
.
That means you need to checkout the correct branch before pushing.
I came here looking for a way to delete remote tag with same name as branch. Following from the Giants comments above, I found this worked:
git push <remote> :refs/tags/<mytag> # or git push origin :tags/<mytag>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With