1

I've been unable to delete this branch from the origin directly, or by creating a local copy.

Sample branch name: sample-branch|name.

A git pull returns Unable to create 'D:/my/git/repo/.git/refs/remotes/origin/sample-branch|name.lock': Invalid argument: Invalid argument

A git checkout sample-branch|name returns error: pathspec 'sample-branch|name' did not match any file(s) known to git.

Using the git branch -d --.... suggestions here, have also failed.

Is there an alternative command or a change to the existing commands that can be used in this instance?

Edit 1: I have tried with and without quotes

ManxJason
  • 928
  • 12
  • 33
  • Can you show the output of `git branch -a`? – mkrieger1 Oct 04 '17 at 11:18
  • And can you clarify what operating system/environment you're on? Looks like Windows, are you using something like Git Bash? – mkrieger1 Oct 04 '17 at 11:20
  • And please show exactly all the commands you've tried, and the complete corresponding error messages. – mkrieger1 Oct 04 '17 at 11:22
  • This may be relevant: https://superuser.com/questions/270004/how-to-escape-pipe-symbol-in-bat-scripts - Maybe you could try using `sample-branch^|name`. – mkrieger1 Oct 04 '17 at 11:26

1 Answers1

1

git branch -d|D is only applicable for local branches. To delete a remote branch, you need to use slightly different command.

git push origin --delete "sample-branch|name" # git version >= 1.7

git push origin :"sample-branch|name" # for older versions
hspandher
  • 15,934
  • 2
  • 32
  • 45