For some time now I’ve had an issue on my local machine with pip installing from git repositories at a specific branch or tag (pip install git+git_repo_url@branch#egg=eggname). I kept on getting the following error:
$ pip install -e git+git://github.com/simplegeo/python-oauth2.git@hudson-python-oauth2-147#egg=python-oauth2
Obtaining python-oauth2 from git+git://github.com/simplegeo/python-oauth2.git@hudson-python-oauth2-147#egg=python-oauth2
Updating ./.virtualenvs/cenper/src/python-oauth2 clone (to hudson-python-oauth2-147)
Complete output from command /usr/local/bin/git rev-parse origin/HEAD:
fatal: ambiguous argument 'origin/HEAD': unknown revision or path not in the working tree.
Use '--' to separate paths from revisions
Command /usr/local/bin/git rev-parse origin/HEAD failed with error code 128
Storing complete log in /Users/nduthoit/.pip/pip.log
After some debugging into pip’s code for git I realized that the name of the branch had some strange stuff at the beginning and end of the actual branch name (origin/HEAD in this case):
And no, that’s not unicode, it’s color code! The red output of the branch name in the error message should have been a clue.
The cause was my .gitconfig’s color setting:
ui = always
I just had to set it to:
ui = auto
And everything worked again!
Morale: don’t be shy of debugging and tracing errors that bug you.