Jan. 29, 2008, 4:03 p.m.

Wanted: Git Cheat Sheet for Collaboration

I've seen a lot of git advocacy lately, and a few comparisons to mercurial, but I've not seen anything that suggests using git over mercurial (my personal favorite) that made me feel that the author had ever used git.

Like many, I am not qualified to describe the differences in any sort of compelling fashion. mercurial feels easier to use to me, but it may just be that git is too foreign and I don't understand it. As I do work with git, I figured it'd be good to find out how I might build similar collaboration patterns to those to which I've grown accustomed. It is for this reason that I'm asking for some command equivalents (or at least some guidance on what I should be doing).

How do I know where I am?

hg command hg identify

In mercurial, I can always ask for tree identity using the command hg identify. The closest I can find in git is git describe, which generally just gives me an error telling me it can't describe the changeset with the given hash. While this does give me something useful, it does so in the form of an error message, which makes me believe that it may not be the right thing.

How do I see the changes in a repo?

hg command hg log

If I git checkout an older revision of a tree, the newer changes simply disappear from the log. This is a bit inconvenient for me, because I generally want to see what's coming up, not just what's got me to the current revision. The current behavior is a valid case, but it's certainly not the only one.

This is especially confusing after a pull. I can see lots of hashes scroll by the screen making me thing git is doing something really important and perhaps I should be able to reverse SHA-1 in my head so I can tell what that is, but when I'm finished, I can't tell what just happened. git log still shows me the state I was in before.

When I do go back to a previous version, how do I get back to the present? I can't see the changes, so I don't know where I'm going. I'm sure there's a simple mechanism somewhere, but it's not obvious to me.

How do I tell what a given upstream needs?

hg command hg outgoing [url or registered alias]

I managed to figure out I can do git log origin.. to get changes that I have that aren't in my concept of what the origin has. How do I do that with an arbitrary URL? Do I always have to register them? Maybe that's OK.

How do I tell what a given upstream may provide me?

hg command hg incoming [url or registered alias]

I haven't figured this one out other than to pull and see what happens (though as I mentioned above, I haven't figured out how to see what's happened, either).

How do I share changes when I have read-only access to an upstream repo?

hg command hg bundle /output/file [url or registered alias]

The above is the easiest way to do it and the way I tell people, but there's also hg epxort and extensions like patchbomb (which is similar to git's format-patch, except it will actually send emails.

Of course, I can also just serve my repo, which is probably the best way to do it in any case. For small changes, that's a bit of a pain, though.

How do I import an exported changeset?

hg command hg import /input/file

The best I've been able to figure out here is git apply, but that doesn't actually save a change, it's just patch with git extension support. Surely there's something that will take an exported changeset and reimport it as it was.

blog comments powered by Disqus