Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to delete a branch that ends in a period

Tags:

git

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?

like image 736
jwieland Avatar asked May 28 '15 17:05

jwieland


People also ask

How do I force delete a branch?

Delete a branch with git branch -d <branch> . The -d option will delete the branch only if it has already been pushed and merged with the remote branch. Use -D instead if you want to force the branch to be deleted, even if it hasn't been pushed or merged yet. The branch is now deleted locally.

How do I delete an unused branch in git?

Here is the Git command to remove a local tracking branch: git branch --remotes --delete origin/name-of-branch-to-remove. git branch -r -d origin/name-of-branch-to-remove.

How do I delete a staging branch?

Alternatively, the user can also use git branch -D <branch_name> to force delete the branch without checking the merged status of the branch. Doing so, Git won't give any warnings even if the branch does not merge in.

How do I force delete a remote branch?

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 .


1 Answers

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 :)

like image 107
Nick Volynkin Avatar answered Oct 16 '22 14:10

Nick Volynkin