read

“You are a developer, software engineer, web designer, text writer… You want your files accessible from all the places (like a source for your project or a template for a website) - and you want to be sure that it is always the most up to date version… Sure you can drag those files along on a USB stick and copy it forth and back. You have those files even if there’s no Internet access. Important? Sure but…”

With MinGW git port (no need for Cygwin!) - git now looks as a great alternative to both Subversion and Bazaar on Windows.

Let’s get things started.

Bazaar-NG is excellent choice, however it is a little tad slow on my shared hosting. While it is comparable at startup time on my Gentoo box it’s startup on Windows box at work can be counted in a few seconds for each command. Git just seems faster for every operation I run.

Repository creation

Let’s assume that you have your precious sources/documents/whatever in ~/src/mypreciousss. We need to create a git repository there and make an initial commit.

cd ~/src/mypreciousss
git init<br />
git add *<br />
git commit -m "Initial commit"

That’s it. You’ve got your repo (+workspace) up and running.

Moving repo to remote host

Now it’s time to move the repo to shared hosting. This may seem a little bit awkward but it’s a little bit easier this way. As we don’t need our working copy on remote host let’s just clone the sole repo:

cd ~/src
git clone --bare mypreciousss mypreciousss.git
touch mypreciousss.git/git-daemon-export-ok

Now you can just scp/ftp mypreciousss.git to any directory on remote host. I’ve set a ~/src/ directory on remote host so the address of repository will look like this:

ssh://user@remote.host.com/~/src/mypreciousss.git

Next thing is to prepare git on shared hosting. This is due to fact, that - contrary to Bazaar ftp access - git needs itself available when using ssh:// protocol to access repository (however the same applies for Bazaar’s bzr+ssh repository access; you need bzr command available for your shell). Just grab it from git’s website, run usual configure+make+make install and make it available in the path (eg. by exporting modified PATH in ~/.bashrc).

Testing

It’s time to test our remote repo. Just to make it a little bit more challenging remove both local repos: ~~~ rm -Rf ~/src/mypreciousss rm -Rf ~/src/mypreciousss.git ~~~

And clone remote repository to local workspace:

git clone ssh://user@remote.host.com/~/src/mypreciousss.git mypreciousss

This should do it.

However there’s one catch: on Linux boxen git will ask for a password for user@remote.host.com while on Windows not (MinGW version at least). This is a common problem. The solution is to have a public/private ssh key created and installed on shared hosting. It will also ease the pain of using authorized access since you either don’t have to remember password for you ssh key (passwordless keys) or use ssh-agent. Second solution is recommended.

Blog Logo

Marcin Gil


Published

Image

When grass was greener

Rants on programming, photography, life and everything

Back to Overview