Posted: January 6th, 2009, 7:33pm CET
div
pEveryone's been talking about how great and wonderful git is, and I've tried using it for a few projects of my own, on a local basis, sort of like an advanced form of 'rcs'. So I thought I'd try it out in a little bit more complicated setup, for a site I host on my web server. I want to have a main repository, that I check out (or 'clone', in git terms) on my laptop. My laptop can't be the main repository, because I also want to be able to commit from the web server (once in a while a quick live update is called for), so I need a stable address. Ok, I'll put it in my home directory on the web server, just to see how things work./p
precodemkdir foobar
cd foobar
git init
/code/pre
pOk, so far so good. Now I try and clone it on my laptop, where I will then add files, commit, then push them./p
pOops, that doesn't work. You can't clone an empty repository./p
pOk, I add something on the server where I init'ed it, an empty file, just to give it some content. Now cloning it works on the laptop. Great, we're in business! I add a bunch of files from the project to the laptop repository, commit, then push them. Seems to be ok so far... I do a checkout on the remote/server machine, and I see my files. Good. Ok, let's try making a change on the laptop. I remove a file, commit it, push it (which is already an extra step compared to subversion... hrmph). I do a checkout on the server, but it won't erase the file I removed on the laptop. Weird. I google around a bit, and find that this is supposed to be for my own good, so I won't wreck things on the server. I need to do codegit reset --hard/code (which isn't a very reassuringly named command) there, and emthen/em a checkout, and now things work. /p
pThat, however, is a lot of work just to commit and update stuff! I ask for some help on #git, where they mention the code--bare/code option to init. Since I'm just messing around, I go back and redo the init step, wiping the old repository. Now I try and clone that to start over again. Oops, I forgot, I can't clone it because it's empty. Grrrrrr.... this is getting annoying./p
pSo, the kind folks on #git tell me I should push to the new server repository from one that's already populated. Ok, let's try setting up the laptop:/p
precodegit init
... add/commit some files ...
git remote add origin ...myurl...
/code/pre
pNow let's try pushing. Nope, still doesn't do it, I'm missing something. Frustrating. A bit more fiddling and googling, and i find:/p
precodeget push origin master
/code/pre
pAha! It worked! Weird. And now a simple git push works too. The whole thing seems kind of shaky in the sense that it's not very confidence inspiring: I feel like it wouldn't take much to make a wrong turn and find all my files gone forever. I can see some of the advantages, and will likely stick with it - git is quite convenient for local files that I might not have bothered putting under version control in the past, but it's also a bit more bureaucratic in that you have more steps to do, and you have to fill in the forms just so... or else!/p /div