0

Not able to delete all local branches. Some special characters are appended in the end and git throws following error:

git branch | grep -v "develop" | xargs git branch -D

error: branch 'anjum_br?[m' not found.
error: branch 'deploy_doc?[m' not found.
error: branch 'deploy_doc_fix?[m' not found.
colidyre
  • 4,170
  • 12
  • 37
  • 53
  • 1
    that looks suspiciously like vt100 escape sequence if the `?` is replaced with ESC key (0x1b) – slebetman Mar 16 '20 at 06:34
  • check the git colourize setting, https://stackoverflow.com/questions/10998792/how-to-color-the-git-console . In theory "auto" mode should be off when you're piping – M.M Mar 16 '20 at 06:40

1 Answers1

0

I suggest you run git branch | grep -v "develop" | od -xcb to get a better representation of what you're seeing. ESC [ m (equivalent to ESC [ 0 m) is the terminal sequence for resetting graphics rendition (coloring and other attributes).

The thing you will be looking for is hex 1b or octal 033.

If that is the case, there's a good chance something is intercepting your streams and injecting these escape sequences into them. The most likely cause is your color.ui being set to always, as shown in the dump below when I set that flag:

0000340    6d5b    200a    6d20    7361    6574    1b72    6d5b    000a
          [   m  \n           m   a   s   t   e   r 033   [   m  \n
        133 155 012 040 040 155 141 163 164 145 162 033 133 155 012

You can see the escape sequence 033 [ m in the output stream in that case. Setting that flag to auto should use color if it detects output being sent to a terminal, no color otherwise:

git config --global color.ui auto
paxdiablo
  • 854,327
  • 234
  • 1,573
  • 1,953
  • Thanks @paxdiablo indeed that is the issue and after setting it to auto the issue got fixed. – Karthik V Mar 16 '20 at 06:57
  • @KarthikV, so presumably that would be a good reason to upvote/accept the answer, yes? :-) – paxdiablo Mar 17 '20 at 03:18
  • Aaargh! I forgot to turn of my `always` setting yesterday and, this morning, got `fatal: remote part of refspec is not a valid name in ?[32mpax-adb9999-fix-device-using-stale-data?[m` when pushing with a script of mine. Can confirm my answer fixes this problem as well :-) – paxdiablo Mar 17 '20 at 03:53