Question

I did few searches and found this alias to keep feature branch in sync with develop branch which works when I run from Git bash manually.

sync='!f() { echo Syncing this branch with develop && git checkout develop && 
git pull && git checkout – && git rebase develop; }; f'

I tried putting this alias in .gitconfig however I'm getting the following error

error: pathspec '"\342\200\223"' did not match any file(s) known to git.

what I found is git checkout -, which stands for, go back to last branch you were on creates this error.

I also tried putting the same command in .bashrc like below

alias sync='echo Syncing this branch with develop && git checkout develop && git pull 
&& git checkout – && git rebase develop'

which creates same error.

However just to make sure when I run all the commands in Git Bash manually they all work fine, so there is no other problem. Seems this is just because of differences in msysgit or bash on windows as I've read these alias work for git on mac and Linux.

Can some enlightened mind tell me how to change it to make it works on windows?

Thanks

Was it helpful?

Solution

\342\200\223 is an octal character sequence representing the UTF-8 "en dash" character: octal 342 200 223 is the same as hex e2 80 93. You probably copy/pasted that command line from somewhere and that character is blowing git's mind. Use an ASCII -.

That is to say, this character: and this one: - are not the same. You need to use the latter.

You can check by running the character through your favourite hex dump program. Here's my example:

$ echo -n – | hexdump
0000000 e2 80 93                                       
0000003
$ echo -n - | hexdump
0000000 2d                                             
0000001
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top