Friday, December 19, 2008

Frustrated with git

I'm a little over a week into a git immersion program.  Let me just say that git's reputation of being a little arcane (okay, more than a little) and having a steep learning curve is 100% deserved.

One thing that would mitigate things is if git would give you feedback when you tell it to do nonsense.  But it doesn't.  Here's me trying to get machine B to always merge the debug branch from machine A when I pull:


232 git config branch.debug.remote origin
234 git config branch.master.remote origin
236 git config branch.master.remote origin/debug

All of these commands completed silently. None accomplished what I wanted. In the end I renamed master to old and debug to master to avoid having to fight it. Then I blew away my working copy and re-cloned because those config statements had created a new problem that I didn't know how to undo.

I'm sure the git virtuosos out there will know what was wrong.  That's not the point.  The point is that the tool gave me no feedback.  It was like git was telling me, "Figure it out yourself.  Or don't.  I don't care."  Which is par for the course with my git experience so far.

4 comments:

Eric Florenzano said...

You touched on my only real gripe with git. I do things fairly frequently that I can't figure out how to undo. Usually a git reset --hard works fine, but sometimes it doesn't.

Christos Trochalakis said...

My version of git (1.6.0.4) explains the situation:

$ git pull
You asked me to pull without telling me which branch you
want to merge with, and 'branch.foo.merge' in
your configuration file does not tell me either. Please
name which branch you want to merge on the command line and
try again (e.g. 'git pull <repository> <refspec>').
See git-pull(1) for details on the refspec.

If you often merge with the same branch, you may want to
configure the following variables in your configuration
file:

branch.foo.remote = <nickname>
branch.foo.merge = <remote-ref>
remote.<nickname>.url = <url>
remote.<nickname>.fetch = <refspec>

See git-config(1) for details.

======

So you have to do something like this:
git config branch.foo.remote = origin
git config branch.foo.merge = refs/heads/master

Now, everytime you pull from the local foo branch it will merge with origin/master

mike bayer said...

Linus should write the error messages personally, so we'd have things like "You didn't specify anything to merge. You really aren't thinking, are you?"

(for reference: http://article.gmane.org/gmane.linux.kernel/542867 )

Andreas said...

Yeah. This is definitely git's weakness. My least favorite one is "You have unresolved conflicts." (or something close to that) when fixing a pull conflict by trying to accept the remote changes over local ones, the way one would with Subversion.

The mailing list answer was something along the lines of 'this is an edge case that rarely happens' rather than 'ok, this reply can be improved'. That sucks.