在我的两台计算机上同步 Rails 开发环境
到目前为止,我一直在使用 TextMate 在 Mac OS X 机器上构建 Rail 应用程序。
我就是这样,所以没用过Git。我刚刚打开和关闭了文件系统中的代码,使用 AppleScript 在关键时刻拍摄带注释的快照,然后让 Time Machine 处理剩下的事情。
我刚刚订购了一台 Windows 笔记本电脑,将用于同一项目。我希望能够在两台计算机之间自动同步所有内容。
我假设我可以使用 Git、Mercurial 或 SVN 同步项目本身。 (无论如何,我必须自学版本控制。)如果通过为小型私人项目提供免费帐户的服务器来进行同步,那就太好了。如果我能够在每个工作块的开始和结束时继续使用 Mac OS X 和 Windows 中的标准“打开”和“保存”对话框,而不是使用版本控制命令,那就太好了。关于如何使其尽可能简单有什么想法吗?
除此之外,我还必须同步 Rails 版本、Ruby 版本、可用的 gem 以及 ImageMagick 等可用的库。我想其中一些可以通过在各种配置文件中指定 Rails 版本等来实现。再说一遍,有什么想法吗?
如果只有您(一台 Mac 和 PC),您的理想方法是什么?
So far I have been building my Rail app on a Mac OS X box using TextMate.
It's just me, so I haven't used Git. I have just opened and closed the code in the file system, used an AppleScript to take annotated snapshots at key moments, and let Time Machine take care of the rest.
I've just ordered a Windows laptop which I'll use for the same project. I'm hoping to sync everything automatically between the two computers.
I'm assuming I can sync the project itself using Git, Mercurial or SVN. (Regardless, I'd have to teach myself version control.) It would be nice to do this syncing via a server that provided free accounts for small private projects. It would also be nice if I could continue to use standard Open and Save dialogues in Mac OS X and Windows at the start and end of each chunk of work, instead of mucking around with version control commands. Any thoughts on how to make this is simple as possible?
Beyond that I'll have to sync the Rails version, the Ruby version, the available gems, and the available libraries like ImageMagick. Some of this I guess I can achieve by specifying the Rails version etc in various config files. Again, any thoughts?
If it was just you, a Mac and PC, what would be your ideal approach?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(5)
我想分享我对这个问题的解决方法。我刚刚开始使用 Rails 进行开发,我使用两台 Windows 机器,一台在工作(老师),一台在家里。我只是想玩弄 Rails,但我希望我在工作/家里所做的事情能够转移到另一台计算机上。当我终于偶然发现了一个适合我的解决方案时,我正打算求助于 Dropbox。
问题:使用 Git
解决方案
在两台计算机上同步 Rails 开发我使用 $rails new app 在 PC1 上创建我的项目。然后,我使用 GIT 提交并将 origin 存储库推送到我的 github 帐户。第二天,在 PC2 上工作时,我使用 git clone 将项目克隆到我的 PC2 上。当测试我的 Rails 应用程序是否工作时,它没有工作。仍然在 PC2 上,我转到 cmd.exe,并在我刚刚创建的同一目录中运行 rails new app。我经历过,不得不手动告诉 Rails 跳过重复的文件。最终结果是两个可以工作的 Rails 应用程序,它们共享一个 github 存储库,我可以在任意一台 PC 上编辑代码文件并将它们发回,然后它们可以在另一台 PC 上运行。
对于一个单独从事项目的人来说,我认为 dropbox 方法是最好的,但我正在尝试学习整个开发过程,所以我想达到使用 git 的程度。
I wanted to share my fix for this problem. I am just beginning development in Rails and I am using two windows machines, one at work(teacher) and one at home. I just want to play around with rails, but I want what I do at work/home to carry over to the other computer. I was about to resort to dropbox when I finally stumbled on a solution for me.
Problem: Syncing Rails Development on Two Computers with Git
Solution
I used $ rails new app to create my project on PC1. I then used GIT to commit and push origin repo to my github account. The next day while at work, PC2, I used git clone to clone the project to my PC2. When testing to see if my rails app worked, it did not. Still on PC2 I went to the cmd.exe and ran rails new app on the same directory I had just made. I went through and had to manually tell rails to skip duplicate files. The end result was two working rails app, that share a github repo, and I can edit the code files on either PC and send them back and they work on the otherone.
For a person working solo on a project, I imagine the dropbox method is best, but I am trying to learn the whole development process so I wanted to get to a point where I was utilizing git.
坦率地说,没有特别简单的方法可以实现您所追求的目标。例如,需要编译的 Gem 和库无法镜像到另一台机器,尤其是不同的操作系统。
但是,如果您不想进行版本控制的麻烦,我可以为您提供一种更简单的方法来管理您的项目,即 投递箱。我目前正在将它用于我的 Rails 项目之一。安装该软件后,它会在您的计算机上创建一个“dropbox”文件夹。每当您将文件保存到其中或更新其中已有的文件时,它都会立即安全地上传到他们的免费服务器,然后下载到每台安装了该软件的计算机上。这允许您继续使用您习惯的“打开”和“保存”对话框,同时还保留对服务器进行的每次更新的历史记录。
它不是版本控制的答案,也确实不是这样的。 Git 和 Mercurial 仍然值得学习,但当您不需要太多控制时,它是一个很好的中间立场和完美选择。即使只是用于一般备份,也值得一看。
PS 我不为 Dropbox 工作,我只是喜欢它。
Quite frankly there is no particularly easy way to achieve what you're after. Gems and libraries that need compiling, for instance, just can't be mirrored to another machine, especially a different OS.
However, I can provide you with an easier way to manage your projects if you don't want the hassle of Version control, which is DropBox. I'm using it for one of my rails projects at the moment. Once you install the software, it creates a 'dropbox' folder on your machine. Any time you save a file into it, or update a file already in it, it's instantly uploaded to their free server, securely, and then downloaded onto each machine that have the software installed. This allows you to continue using the Open and Save dialogues you're used to while also keeping a history of each update you make to the server.
It is not an answer to Version Control, and it really isn't meant to be. Git and Mercurial are still worth learning, but it's a good middle ground and perfect when you don't need so much control. It's worth a look, even just for general backup.
P.S. I don't work for dropbox, i just love it.
我强烈建议您在 Github.com 上开设一个免费帐户并自学 git。学习命令行并不需要很长时间,一旦开始使用它,您就会明白为什么命令行保留至今。
另外,虽然我没有使用过它,但这里似乎有一个很好的 TextMate Git 包:
http://gitorious.org/git-tmbundle
I really suggest opening a free account at Github.com and teaching yourself git. Learning the command line does not take long and once you start using it you can understand why the command line persists to this day.
Also, though I have not used it, there appears to be a good Git bundle for TextMate here:
http://gitorious.org/git-tmbundle
我同意 GIT 是管理版本控制的好方法,但另一种方法是使用虚拟机。这意味着您可以在 VMWare 或 VirtualBox 下的 Ubuntu 下创建开发环境,然后将虚拟映像从一台计算机复制到另一台计算机。这样,您就不必为不同的操作系统进行两次设置,这可能是一个真正的痛苦。使用这种技术意味着在 Mac 和 Windows 下一切都一样,如果您只更改了源代码,那么您仍然可以使用 GIT 来保持图像最新。
I agree that GIT is a great way to manage the versioning, but another way is to use a virtual machine. This means that you create your development environment under Ubuntu under VMWare or VirtualBox, and then copy the virtual image from one machine to another. This way you don't have to set everything up twice for the different operating systems, which can be a real pain. Using this technique means everything works the same under the Mac and Windows, and if you only have source code changes then you can still use GIT to keep the images up to date.
我想我应该写一个对这个老问题的更新。我确实使用 Dropbox 来同步代码和 git 存储库。我发现这部分非常简单,而且我的代码永远不会过时。更大的问题是处理依赖关系。如今,这比以前容易得多,因为当您坐在不同的机器上时,您的 gemfile 已同步,您只需“捆绑安装”即可。几乎任何你忘记的东西都会抛出一个错误,这就像一个友好的提醒,你必须使用 rvm 来使用它,或者使用 brew install 来安装它。您已经在一台机器上完成的事情,因此不需要太长时间就能弄清楚。
关于 Git:Git 不同步任何内容。它用于保存代码(“提交”)或保存备用版本(“分支”)。它还用于推送到远程备份(如 Github)或部署服务(如 Heroku)。我曾经以强烈的热情讨厌它。我知道它应该帮助我控制版本,但不知道它是如何工作的并且不信任它。如果我正在进行重大更新,我会将应用程序目录复制到备份。几年后,我像寿司厨师挥舞刀一样挥舞 git,熟练地分离分支、合并,偶尔重置——很难。
学习 Ruby/Rails 比学习使用 Git、RVM 和 Homebrew 等工具要少得多,但它们也是让 21 世纪的编程变得有趣和高效的重要组成部分。
I thought I'd write in an update to this old question. I do indeed use Dropbox to sync code and git repositories. I find this part very easy, and my code is never out of date. The bigger problem is dealing with dependencies. Nowadays, this is a lot easier than it used to be because when you sit down at your different machine your gemfile is synced and you can just 'bundle install'. Pretty much anything you forget will throw an error, which is just like a friendly reminder that you have to rvm use this, or brew install that. Stuff you already did on one machine, so it doesn't take too long to figure out.
About Git: Git doesn't sync anything. It's used to save code ("commits") or save alternate versions ("branches"). It's also used to push to remote backups (like Github) or deployment services (like Heroku). I used to hate it with a vigorous passion. I understood that it was supposed to help me control versions, but didn't know how it worked and didn't trust it. If I was working on a big update, I would copy the app directory to a backup. After a few years, I wield git like a sushi chef wields his knife, deftly separating branches, merging, and occasionally resetting --HARD.
Learning Ruby/Rails has been a lot less work than learning to use tools like Git, RVM, and Homebrew, but they're also a big part of what makes programming in the 21st century fun and productive.