Git Fail

I ran into a pretty lame Git problem while I was setting up a new repo today. In a nutshell: If you haven’t commited to your new repo, you cannot unstage files from Git.

I was setting up a new Django project, and I had used virtualenv to install Django and my dependencies locally. I then created my project, an app, tweaked the settings and so on, and went to add this stuff to Git. One git init; git add . later, I realize that it’s adding all the virtual environment stuff in lib and include.

Whoops! Let’s just unstage that:

electron!ieure:~/Projects/new$ git reset lib
fatal: Failed to resolve 'HEAD' as a valid ref.

Oops. We can’t unstage it, because there’s no HEAD to compare to. I don’t know if there’s some arcane magic to make this actually work, but I ended up blowing away .git and starting over.

Git is pretty nice, but I dislike the little gotchas like this.

2009/10/25
Previously On Atomized:

Participate