SVN 提交/更新存储库

发布于 2024-10-30 04:38:55 字数 228 浏览 4 评论 0原文

我只是想知道一些事情,我正在与其他几个程序员一起开发一个项目,我们都使用 SVN 来完成该项目,我将 svn 树下载到我的本地计算机上,每当我更新某些内容时我都会提交它,到目前为止,一切都很好。

如果:

  1. 我正在处理本地版本,更新 XXX.cpp(版本 1)中的内容,而其他人上传该 XXX.cpp 的版本 2,然后我上传我的版本,我的“旧”版本会覆盖新版本吗?

谢谢,

I was just wondering about something, I'm working on a project with several other programmers, we all use SVN for the project, I downloaded the svn tree to my local computer, and whenever I update something I commit it, up to now, everything is fine.

What if:

  1. I'm working on my local version, updating stuff in XXX.cpp (version1) while someone else uploads version2 of that XXX.cpp, and then I upload my version, will my "older" version overwrite the newer one?

Thanks,

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(8

影子是时光的心 2024-11-06 04:38:55

SVN 将尽力合并两个开发人员所做的更改。如果您正在处理文件的不同部分,它很可能会毫无问题地处理此问题。如果两个开发人员都在更改文件的相同行,或者由于任何原因合并比 SVN 可以处理的更复杂,它会将文件标记为冲突,并要求您手动合并冲突(使用 diff 工具)。尝试更新您的本地更改。

基本上,当您尝试提交时,SVN 会告诉您有更新的更改,您应该首先更新。当您更新时,它将在您的本地计算机上进行合并。在提交之前需要修复冲突的文件。一旦它们被修复并合并所有更改,您就可以提交。

SVN will do its best to merge the changes both developers have made. If you're working in different parts of the file, it'll most likely handle this without a problem. If both developers are changing the same lines of the file, or for whatever reason the merge is more complicated than SVN can handle, it'll mark the file as conflicted and ask you to merge the conflicts manually (using a diff tool) when you try to update your local changes.

Basically, when you try to commit SVN will tell you that there are newer changes and you should update first. When you update it will conduct the merge on your local machine. Conflicted files will need to be fixed before you can commit. Once they're fixed and all changes merged, you can commit.

天暗了我发光 2024-11-06 04:38:55

第二个人提交具有相同修订版的同一文件将收到“SVN 冲突”错误,并由他们来解决。参见例如:http://ariejan.net/2007/ 07/04/如何解决颠覆冲突/

The second person to commit the same file with the same revision will get a "SVN conflict" error, and it will be up to them to resolve it. See e.g. this: http://ariejan.net/2007/07/04/how-to-resolve-subversion-conflicts/

揽清风入怀 2024-11-06 04:38:55

这是版本控制软件的要点之一,将会发生以下情况:

  • 有人签入文件 A
  • 其他人尝试签入文件 A< /code>
  • SVN 将尝试自动合并文件
    • 如果一切顺利,就煮杯咖啡
    • 呃哦,检测到冲突(需要人工干预)
      • 更改由提交者手动检查和确认

最后一部分是事情变得棘手的地方 - 没有人愿意这样做。

另外,SVN 有一个可怕的习惯,有时在合并时会自行损坏源文件,用 <----- 我的<------ 污染代码他们的左、右、中——在所有情况下都需要小心。

有很多或场景可以解释,以帮助您在该领域进行教育,但这涵盖了一般概念,并且随着经验和实践,许多其他知识将随之而来。

This is one of the main points of version control software, and this is what will happen:

  • Someone checks in file A
  • Someone else tries to check in file A
  • SVN will try to auto-merge the file
    • If all is good, make a coffee
    • Uh oh, conflict detected (needs human intervention)
      • Changes are manually checked and confirmed by the submitter

The last part is where things get tricky - nobody wants to have to do this.

Also, SVN has the terrible habit of sometimes corrupting your source files all by itself when it merges, polluting code with <----- mine and <------ theirs left, right and centre - care needs to be taken in all cases.

There are a bunch or scenarios which could be explained to help educate you in this area, however this covers the general idea and a lot other knowledge will come with experience and practice.

魔法唧唧 2024-11-06 04:38:55

建议在提交之前始终进行更新。

It is recommended, to always update before doing commit.

若相惜即相离 2024-11-06 04:38:55

我认为 SVN 会检测到当前文件与您正在使用的基本版本不匹配,并要求您进行手动合并。

I think SVN will detect that the current file does not match the base version you were working with and ask you to do a manual merge.

玩物 2024-11-06 04:38:55

它不会覆盖它,但您修改的版本将成为最新版本。您需要将工作副本中的更改合并到先前的修订版本中。

如果您正在处理单独的逻辑单元并对同一代码库进行更改,我建议您对任务进行分支,并在完成后从分支合并到主干。

It won't overwrite it, but your modified version will become the latest revision. You'll need to merge your changes from your working copy to the previous revision.

If you're working on separate logical units with changes to the same code-base I'd recommend you branch your tasks and merge from branch to trunk once completed.

固执像三岁 2024-11-06 04:38:55

大多数时候 SVN 会尝试合并更改。如果不可能,它会向您显示一条消息,表明您的提交失败,您需要在尝试再次提交之前更新结账。

该新更新可能会给您带来需要解决的冲突。
不过,它永远不会覆盖以前的更改。

Most of the time SVN tries to merge the changes. If that is not possible it will give you a message that your commit failed and you need to update your checkout before trying to commit again.

That new update might give you conflicts that needs to be resolved.
Though, it will never overwrite previous changes.

东风软 2024-11-06 04:38:55

实际上,第二个开发人员在提交之前并不知道该文件是否被其他人修改过。一旦他提交,就会发出版本冲突的警告(因为他修改的文件版本已经被其他人修改过)。
然后您可以解决冲突,但我认为每个开发人员都应该在每次提交之前执行 SVN-UPATE,然后您就可以克服任何不需要的情况。

Actually 2nd developer don't know whether the file was modified by others or not before his commit. As soon as he do commit, it will give warning for version conflicting (because the file version from which he has done modification it has already been modified by others ).
You can then resolve the conflict BUT I think each developer should do SVN-UPATE before each commit, then you can overcome any unwanted situation.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文