Notes on Life, ‘Puters and Hawaii

Keeping your git projects up to date with sake

I have been keeping all my projects in git repositories regardless if they came from git or svn. I probably have about 3 dozen projects at any one time in my ~/Projects dir. Keeping them all up to date is a PITA. So I wrote a little sake task to find them all and update them. Here it is:

desc "Recursively update your git projects"
task "git:update" do
  `find #{File.expand_path('.')} -name .git -type d`.collect { |d|
    d.chomp("/.git\n")
  }.each do |prj|
    puts(prj)
    Dir.chdir(prj)
    `git config --get svn-remote.svn.url`.empty? ?
      `git remote update` : `git svn fetch`
  end
end

Leave a Reply