Reputation: 23
I have a problem with deleting git branch. At first I was able to create it using 'git checkout -b ....'. But it seems to me, that I made a mistake while writing, hit something wrong, then backspace. It resulted in wrong name of this branch.
I was able to work on this branch, even push it to remote, but it makes weird behavior (cannot see branches in web interface).
git branch -r shows me
origin/master
origin/rrseria_test_utility
In web interface (bitbucket) I can see this branch in commits with following name
rrseriaÅl_test_utility
Pleasse note that capital A is not just A, but A with circle above. Seems like utf-8 character 'U+00C5'.
When I try to remove it, then
git branch -d rrseria_test_utility
error: branch 'rrseria_test_utility' not found.
git checkout rrseria_test_utility
error: pathspec 'rrseria_test_utility' did not match any file(s) known to git.
Can you help me how to delete this branch ?
Upvotes: 2
Views: 737
Reputation: 72177
You can use git branch --list rrseria*
to list only the branches whose names start with rrseria
. If there are more than one you can use a more specific pattern, using the *
wildcard for the non-ASCII characters (rrseria*l_test_utility
f.e.).
This command displays the name of the branch you want to delete.
If you are on Linux or macOS, you can use its output to create the Git command to delete that branch:
git branch -d $(git branch --list rrseria*)
Or you can use the mouse to copy the branch name in the terminal window from the output of git branch --list
and paste it (back into the terminal window) to create the git branch -d
command.
Or you can use your favorite file manager to navigate in the .git/ref/heads
directory and remove the file whose name matches the branch name (this is what git branch -d
does in the background).
After that you have to push the deletion to the remote repositories:
git push origin --prune refs/heads/*
If you have more than one remote then repeat the command above for each of them (put its name instead of origin
).
Upvotes: 2