Tuesday, September 6, 2011

git and nomad life

This entry is like a note to myself, just to help remember setting this thing up again if needed...

So I have my track creations in a public git repo at repo.or.cz.
So far I've only been using it to publish my ideas to the world, but now my time schedule has changed and I wanted to gain full access from another computer, too.
I had no problems using git clone to clone the project on the new computer. Then I've set up some tracking branch with 'git branch -t track_name origin/track_name', fetched it with 'git fetch origin' and began working on it after the merge: 'git merge origin/track_name'.
But then after some changes I wanted to push them to the repo, so I could continue work on the other computer. However I could not get it working unless adding a new user at repo.or.cz/reguser.cgi. It also meant generating a new SSH key with ssh-keygen, and copying the public key to the appropriate edit field on the register page.
Then I've edited the file .git/config and added a new line in the section '[remote "origin"]' a new line, right after the fetch URL line:
pushurl = ssh://newusername@repo.or.cz/srv/git/kilo_torcs_tracks.git

Now I can fetch the whole thing issuing 'git fetch origin track_name' and push to it 'git push origin track_name'. The server asks for the SSH passphrase and voila it works.
Right, it may be obvious for some, but I am happy now and wanted to share it :D

Note #1: you may ask why did I not use my existing pubkey to register. Simple: forgot where my USB stick with my pubkey was, and did not want to wait 3 more days with the whole procedure when I got back to the same situation... yes I know, I am lazeeeeehhhh.

Note #2: remember, don't git pull, rather git fetch and then git merge... Details here and here.