Posted in Workflow

Rake tasks

You can see a full list of the tasks rake can automate by typing

rake -T

but you’re also able to create custom tasks of your own that you can run using rake.

You write the whole thing in ruby, and you do it in your project’s lib/tasks directory. Create a new file there, named whatever you like, and give it the filetype/ending .rake

You then add tasks to the file, which’ll be run whenever you run the task. eg:

task :greet do
  puts "howdy"
end

This means you can now run this task from the terminal, with the command:

rake greet

You can also use namespacing to get the little notice:the:colons effect (eg db:migrate). For example

namespace :annotate do
   desc "annotate your models!"
   task :models, :needs => :environment do |t, args|
      exec "annotate --exclude tests,fixtures -p before"
   end
end

This task can now be run by typing:

rake annotate:models

Read more here:

Advertisements
Posted in Workflow

Setting up a second machine to work with your existing github repository, redux

So seems I didn’t have it quite right here, as I discovered when after doing some work I decided to push my new branch up to github. git clone doesn’t seem to do the same thing as git remote add at all, in that it didn’t create the relationship between git (my local work) and github (my backup) necessary to push my work back up.

What I wound up doing (along with a likely embarrassing amount of regenerating ssh keys and scratching my head):

$ git remote add github git@github.com:myUsername/myProject.git

$ git remote -v (should show both push and pull locations set up as above)

$ git branch my-new-branch

$ git push github my-new-branch

If my-new-branch hasn’t been set up on your github project already, that last command will do so automatically, as well as uploading your new work up there in the same command.

Posted in Workflow

Setting up a second machine to work with your existing github repository

I’ve been working on a PC and backing up to github, but with a Macbook Air at my disposal, why bother sitting up at the computer? 😛  To set up your second machine (y’know, the one you can balance on your belly in bed) to access an existing github repository, pull down the files and then push the changes back up:
git init
git remote add origin git@github.com:username/repo.git
git pull origin master
/* work, work, work... */
git commit -am "comments on changes"
git push origin master

Or, to combine a few of those steps:
git init
git clone git@github.com:username/repo.git
/* work, work, work... */
git commit -am "comments on changes"
git push origin master

(git clone does the same as git remote add origin and git pull origin master)

(See follow-up post here to explain the struck-out text here.)

To keep both repositories in sync, you’ll want to pull the latest changes to your machine before you start work.

Via StackOverflow