LandonSchropp
LandonSchropp

Reputation: 10234

Identifying an escaped character

I have a handy little alias for deleting any Git branches that have been merged into the current branch:

alias git_delete_merged_branches='git branch --merged | grep -v "\*" | xargs -n 1 git branch -d'

This has been working fine until I updated to the most recent version of Git (2.9), where it suddenly quit working with this error:

error: branch 'blah' not found.

If I run git branch --merged | grep -v "\*", I get the following output:

  blah

That seems to be correct, and if I run echo " blah\n" | xargs -n 1 git branch -d everything works fine. I suspected there might be a hidden character getting added by Git, so I ran git branch --merged | grep -v "\*" | cat -v and this is the result:

  blah^[[m

What is the ^[[m character and how can I get rid of it?

Upvotes: 0

Views: 43

Answers (2)

Diego Torres Milano
Diego Torres Milano

Reputation: 69189

Check the content of your .gitconfig file.

You should have something like

[color]
    ui = auto

and it should disable colors when output to a pipe.

Upvotes: 3

CodeWizard
CodeWizard

Reputation: 141946

Its is something on your local machine -
I have tried it both on windows and Unix and it works fine for me.

enter image description here

Upvotes: 1

Related Questions