jwieland
jwieland

Reputation: 223

How to delete a branch that ends in a period

Somehow one of my coworkers was able to create a branch ending with a period. I'm not sure how he did it. It's now causing issues when working with his remote.

The bad branch is: 'bugfix_ESP-924-invalid-email-error-message.'

When I do a git fetch taylor it just hangs.

When I list the branches the period is invisible

git branch -r | grep 924
taylor/bugfix_ESP-924-invalid-email-error-message

If I try to delete the branch without the period, I get a 404 (makes sense)

git push origin :taylor/bugfix_ESP-924-invalid-email-error-message
error: unable to delete 'taylor/bugfix_ESP-924-invalid-email-error-message': remote ref does not exist

If I try to delete the true branch name I get a 'invalid branch name'

git push origin :taylor/bugfix_ESP-924-invalid-email-error-message.
fatal: remote part of refspec is not a valid name in :taylor/bugfix_ESP-924-invalid-email-error-message.

Any suggestions?

Upvotes: 11

Views: 209

Answers (1)

Nick Volynkin
Nick Volynkin

Reputation: 15139

A branch is just a link to a commit. It's stored in .git/refs/heads/branchname. If you can access remote directly, just delete the file. But please make a backup before. Two backups are even better :)

Upvotes: 1

Related Questions