在笔记本电脑和台式机上的 ubuntu VM 中进行编码
在虚拟机和中央 SVN 存储库之间管理代码的最佳方式是什么?
更具体地说,我有一台具有 Linux VM 环境的台式机,以及一台具有 Linux VM 环境的笔记本电脑。两者都在VMWare工作站下运行。我一直在台式机和笔记本电脑之间来回切换,但很难保持台式机和笔记本电脑同步。
最明显但可能效率最低的选择是在切换机器之前提交所有内容。然而,这会导致提交部分完整的代码,这样我就可以在不同的机器上工作。
我考虑过使用 rsync 之类的东西来保持我的两个开发环境同步。我认为这会更好,因为这样我仍然可以在需要时向 svn 提交更改,同时保持台式机和笔记本电脑同步。
因此,虽然我很想走 rsync 路线,但我仍然担心我必须主动同步内容。就我而言,我正在想象这样一个场景:我正在台式机上处理一些事情,然后离开去咖啡店用我的笔记本电脑工作,却发现我在离开家之前没有同步(卫生部!)。
我不知道是否真的有什么办法可以解决这个问题。也许我可以将所有内容同步到始终在线的集中式服务器?并设置 cron 作业每隔几分钟运行一次或与我的各种开发环境同步?
有更好的选择吗?
What is the best way to manage code between VMs and a central SVN repository?
To be more specific, I have a desktop with a linux VM environment, as well as a laptop with a linux VM environment. Both are running under VMWare workstation. I switch back and forth between desktop and laptop all the time, but have trouble keeping the desktop and laptop in sync.
The most obvious--yet probably least efficient--choice is to just commit everything before I switch machines. However, this leads to committing code that is partially complete, just so I can work on a different machine.
I've considered using something like rsync to keep my two development environments in sync. I think this would be better because then I can still commit changes to svn when I want to, while keeping both desktop and laptop in sync.
So while I'm tempted to go the rsync route, I'm still concerned that I have to proactively sync things. In my case, I'm picturing a scenario where I'm working on something on my desktop, then leave to go to a coffee shop to do work with my laptop, only to realize that I didn't sync before leaving the house (DOH!).
I don't know if there's really any way around this. Maybe I could rsync everything to a centralized server that's always online? And set up cron jobs to run every few mins or whatever to sync with my various development environments?
Is there a better option?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您可以考虑使用分布式版本控制。如果您没有能力更改中央服务器,仍然有像 git-svn 这样的包装器允许您在终端上使用 git,同时与 Subversion 服务器交互。
DVCS 设置中的工作流程:
当实际推送到服务器时,无论您所在的哪台计算机都应该具有最新的代码,并且您可以推送到主服务器(SVN 或其他服务器)。
这确实会让您提交中间更改 - 但我发现这更多是使用 DVCS 的好处而不是负担。
另一种方法可能是将整个开发目录保存在 Dropbox 文件夹或类似文件夹中。这样你就不必自己处理 rsync 或其他任何事情,但你对同步的控制权就会减少。
You could consider using distributed version control instead. If you don't have the ability to change the central server, there are still wrappers like git-svn that allow you to use git on your end, while interacting with a Subversion server.
The workflow in a DVCS setup:
When it's time to actually push to the server, whichever computer you're on should have the latest code and you can push up to the master server (SVN or whatever).
This does make you commit intermediate changes - but I've found that to be more of a benefit of using a DVCS than a burden.
An alternative to this might be to keep your whole dev directory in a Dropbox folder or some equivalent. Then you don't have to deal with rsync or anything yourself, but you have less control over syncing.
syncd 可能就是您正在寻找的:https://github.com/drunomics/syncd。它使用 inotify 和 rsync 来侦听文件系统更改,并将更改的文件同步到远程服务器。
不过,这是一种单向同步,因此当您停止在一台计算机上工作并在另一台计算机上启动它时,您必须停止它。您还需要在两台计算机上运行 ssh 服务器。
syncd may be what you are looking for: https://github.com/drunomics/syncd. It uses inotify and rsync to listen for file system changes rsync changed files to a remote server.
It is a one way sync though, so you will have to stop it when you stop working on one machine and start it on the other. You will also need to have ssh server running on both machines.