Monday, May 05, 2008

Tracking rails code deployed with git

With git and multiple remote repositories I decided that it would be really nice if I had a branch ref in my local repository that points at the currently deployed version of my code. You could do capistrano tasks and update a branch in the central repository when you deploy code, but I found an easier way that works for my small project. I only have one app server, and I use the remote_cache strategy so this option is easy.
  1. I put a reference to .../myproj/current in my local .git/config file:
    1. [remote "servername"]
      url = ssh://user@appserver/project/path/current
      fetch = +refs/heads/deploy:refs/remotes/deployed/servername
  2. Run "git fetch", and I have a remote ref that points to the code currently on the app server regardless of the success of any other code that may or may not have run.
I really love using git-rev-list and gitk with my deployment remote refs to double check before I deploy.

1 comment: