2

I have a Rails 3.2.16 app with multiple git branches (for testing features). I use thin to spin up a server in development. If I have a branch called "dev" for instance and I'm currently checked out to that branch in git. By default thinwill pickup whatever is in the app directory and serve it up. But what if I wanted serve up what is in the master branch. Is there any way to serve up the master branch in thin (or even in rails s so I can work with the app in that branch in a browser?

So basically I have multiple branches, but want to test the app in the browser using a certain branch. How can I do that?

Michael Durrant
  • 93,410
  • 97
  • 333
  • 497
nulltek
  • 3,247
  • 9
  • 44
  • 94

1 Answers1

3

locally you switch to the branch you want

git checkout master

and

rails server

bring up the app for that branch

You can

git checkout dev

or

git checkout master

at any point in order to run

rails server

for that branch

You don't even need to restart the server for simple applications.

"By default thin will pickup whatever is in the app directory..." - yes but it will do this for the branch that is currently checked out.

So basically which ever branch you are currently on is the same one that is used in your rails server as it is for looking at and editing the files locally. If you switch branch, then both your code and the server will be looking at the files as they exist in that branch.

Michael Durrant
  • 93,410
  • 97
  • 333
  • 497
  • Thanks, this seems to have worked. I've just started using branches and hadn't tried this yet. But switching branches and restarting rails or spinning up `thin` works. I appreciate your quick answer. – nulltek Oct 18 '14 at 12:18
  • np. took me a while to really understand git. I've also posted what I learned at http://stackoverflow.com/a/9204499/631619 which might help you. – Michael Durrant Oct 18 '14 at 12:22
  • and remember you can switch branches 'in-flight' without restarting the server. Mostly because development mode mostly avoids caching. – Michael Durrant Oct 18 '14 at 12:25
  • This is extremely useful. I've been using git for a couple of years but just recently started using branches and really leveraging it's power to isolate feature branches. I appreciate all your help, Michael! :) – nulltek Oct 18 '14 at 13:02