简体   繁体   English

Rails-如何使用特定的git分支启动本地服务器(瘦)

[英]Rails - how to start up a local server (thin) with a specific git branch

I have a Rails 3.2.16 app with multiple git branches (for testing features). 我有一个带有多个git分支的Rails 3.2.16应用程序(用于测试功能)。 I use thin to spin up a server in development. 我使用thin来启动开发中的服务器。 If I have a branch called "dev" for instance and I'm currently checked out to that branch in git. 例如,如果我有一个名为“ dev”的分支,而我目前已在git中签出到该分支。 By default thin will pickup whatever is in the app directory and serve it up. 默认情况下, thin将提取应用目录中的所有内容并将其提供。 But what if I wanted serve up what is in the master branch. 但是,如果我想提供master分支中的内容,该怎么办? 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? 有什么方法可以在瘦(甚至在rails s服务master分支,以便我可以在浏览器中使用该分支中的应用程序吗?

So basically I have multiple branches, but want to test the app in the browser using a certain branch. 所以基本上我有多个分支,但想使用某个分支在浏览器中测试应用程序。 How can I do that? 我怎样才能做到这一点?

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. “默认情况下,thin会拾取应用程序目录中的所有内容...” -是的,但它将对当前已签出的分支执行此操作。

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. 因此,基本上,您当前在哪个分支上都与rails server使用的分支相同,因为它用于在本地查看和编辑文件。 If you switch branch, then both your code and the server will be looking at the files as they exist in that branch. 如果切换分支,那么代码和服务器都将查看该分支中存在的文件。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM