Thursday, August 23, 2007

git-svn again

I'd been having trouble figuring out git-svn and git. I worked at it a bit more this week and I've finally got something working.

mkdir svn-git
git-clone [URL]
cd [directory]

and the files are there. I can do most of the basic things. I haven't yet practiced branching and merging. I'll do that in a week or so. Or tomorrow, as the mood arises. For now, I'm happy that I can remotely mirror a repository (my personal backup of the entire repository, including commit messages). It also makes viewing log messages a lot faster when the svn server is far or my link to it is slow (as happened to me and sol the past three nights, the route to the svn server passed through an ISP in singapore that was experiencing 50% packet loss, it took a few days the upstream ISPs to figure out that they shouldn't go through that lame router).

I had some confusion earlier since I deleted a subdirectory (with just rm -rf) and then couldn't figure out a way to revert. I still don't know how to revert from a "pristine copy", if git has that at all. Instead, what I had to do was a local commit and then a git-revert (which reverts a commit, something that svn doesn't have yet). I don't know if that's the canonical way to do that, but it worked.

I tested git-commit and git-svn dcommit and that worked pretty well. The commit messages are clean, which is my main issue. I'm looking into git-svn partly so that I'll be able to work with version control even if not connected to a repository. I'd previously used svk but wasn't happy with the format of the commit messages pushed into svn when it came time to merge back into svn. That might have improved by now, but then there were problems with speed too. Those won't be fixed except by rewriting in something faster than perl. If I learn, like, and learn to like git, I'll stick with it for disconnected work.

But first I need to test out its features. There's a long weekend coming up (two long weekends in a row this month), I'll play with git a bit then.

[Update]
Ok, The git workflow description at Calice points me at git reset. So

git-reset --hard HEAD

does what git commit+git revert does, but without the bogosity of actually having a commit message in the logs.

Now I'm trying to figure out how to get the list of files modified in a given commit (in svn, svn log -v).

Ah well, now it's just time read the git manual. I read the CVS manual and the SVN manual, I should be able to wrap my brain around git :-).

3 comments:

Ealden Escañan said...

You could use `git checkout -- /path/to/file`.

http://blog.ealden.net/article/appfuse-and-git-over-a-long-weekend

Bopolissimus X Platypus said...

I looked at git checkout, and tried a few variations. I couldn't get it to work right though (need to read the manual, really ;-).

git reset feels like a better solution though for this particular issue. But I'll keep git checkout in mind. Thanks.

Ealden Escañan said...

Strange. I just tested it on a directory that I had added into git:

rm -rf test
git checkout -- test

Should bring back the directory.