使用 SVN 如何防止其他开发人员覆盖我?
我不知道该怎么做。我刚刚开始在一个实际项目中使用 SVN。我一切正常。但是,我是唯一一个使用它的人。现在我想向第二个人介绍这个过程。
我在我的 Windows 机器上下载了 tortoisesvn 并检查了主干。我可以编辑文件并提交新文件。一切正常。
现在,当我正在做某事时,我希望第二个人也这样做。通常他可能正在处理另一个文件,我们会同意将提交的文件导出到测试服务器的时间(无论如何我的想法),但是如果我们正在处理同一个文件怎么办?例如,配置文件。也许我们都需要改变它。当其他人改变它时,我(或他)如何才能阻止另一个人参与其中。如果我们中的一个人提交了新的更新,它将删除我们中的一个人刚刚放入的内容。不知道在这里该怎么做。
I'm not sure how to do this. I just started using SVN on a real project. I have everything working correctly. But, I'm the only one using it. Now I want to introduce a second person to the process.
I downloaded tortoisesvn on my windows machine and did a checkout of the main trunk. I can edit a file and commit my new file. Everything works.
Now, I want the second guy to do it, while I am doing something. Usually he might be working on another file and we would agree on a time to export our committed files to the test server (my thought anyway), but what if we are working on the same file? for example, a config file. Maybe we both need to change it. How can I (or he) keep the other one out of it while someone else changes it. If one of us commits a new update it will erase what one of us has just put in. Not sure what to do here.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(5)
使用 SVN,目标不是抓取文件并说“这是我的,不要碰它”。目标是在你们都完成后合并你们的更改。两个人真正进行不兼容更改的情况很少,当发生这种情况时,开发人员需要聚在一起寻找合并它们的最佳方式 - 而不是争夺谁先赢得文件锁。
始终在提交之前更新,以便将他们的更改与您的更改合并。
With SVN, the goal is not to grab a file and say "This is mine, don't touch it". The goal is to MERGE your changes when you are both finished. The number of cases where two people are truly making incompatible changes are small and when they happen, the developers need to get together on the best way to merge them - as opposed to having a race to who wins the file lock first.
Always Update before Commit, so that you merge in their changes with yours.
不,它不会删除任何东西。
如果两个人更改文件并尝试提交它,则第二个提交的人将收到一条错误消息,指出该文件自上次更新以来已被更改。
然后第二个人进行更新。如果 SVN 可以做到这一点,它将合并它们,保留两个人的更改。如果它不能(通常只有当您在文件中的同一位置更改某些内容时才会出现这种情况),它会告诉您并且您将必须处理冲突。
No, it will not erase anything.
If two people change a file and try to commit it, the second person to commit will get an error message saying the file has been changed since their last update.
That second person then does an update. If SVN can do so, it will merge them, preserving the changes of both people. If it cannot (usually only the case if you change something in the same place in the file), it will tell you and you will have to handle the conflicts.
听起来您需要对 SVN 的工作原理有基本的了解。我建议您阅读版本控制模型部分来自书。
It sounds like you need a basic understanding of how SVN works. I suggest you read the section Versioning Models from the book.
这个问题不会发生,因为 Subversion(实际上任何像样的 SCM)只会让您在执行更新后提交。如果 Subversion 无法合并您的更改,则会导致冲突,您必须手动解决该冲突。
This problem cannot occur because Subversion (any decent SCM actually) will only let you commit AFTER you have performed an update. If Subversion cannot merge your changes, it will cause a conflict, which you have to resolve manually.
SVN 在极少数情况下需要使用锁。查看 SVN 书籍的“锁定”部分以获取更多详细信息。
SVN has locks in the rare case that you need to use them. Check out the Locking section of the SVN book for more details.