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