In an attempt to create a tracking branch I have managed to create a local branch named '-t'. I cannot delete the branch because the branch name is also a parameter. This is on a windows machine.
$ git branch -D -t
fatal: branch name required
Escaping doesn't help either
$ git branch -D \-t
fatal: branch name required
Placing the branch name in quotes does not help either
$ git branch -D "-t"
fatal: branch name required
Using the git gui to try to delete the branch gives the same error message.
I was thinking of just deleting '-t' from .git/refs/heads - Is that enough? Or is there more to it than that? Or is there a way that can delete it from the command line?
Deleting remote branches 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 .
Remove All Local Branches not on Remote First we get all remote branches using the git branch -r command. Next, we get the local branches not on the remote using the egrep -v -f /dev/fd/0 <(git branch -vv | grep origin) command, Finally we delete the branches using the xargs git branch -d command.
Use the --
option
git branch -D -- -t
As you can read here
a double dash (
--
) is used in bash built-in commands and many other commands to signify the end of command options
Git won't treat -t
as an option anymore, since it comes after the --
.
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