SVN 替换特定文件的命令

SVN Replace command for particular file

我的分支中有文件 text.jsp。我想把这个文件提交到主干中。

我已经检查了 trunk 文件夹,并导航到 trunk 文件夹中的 text.jsp 文件位置。

替换的命令是什么。我试过下面的命令

svn 替换 text.jsp https://mybranch/text.jsp

svn 命令提示符中正确的命令是什么。

最好的方法是使用 svn merge 命令,因为它会在 trunk

中保留 text.jsp 文件的完整提交 log/history

svn merge --accept theirs-full https://mybranch/text.jsp https://mytrunk/text.jsp

如果存在合并冲突,您需要使用 --accept theirs-full 选项强制忽略它们,因为您想要替换文件。


如果您不想在主干中保留 text.jsp 文件的完整提交日志,请这样做。 (注意这样commit log会重新启动)

  • svn delete https://mytrunk/text.jsp
  • svn copy https://mybranch/text.jsp https://mytrunk/text.jsp
  • svn commit

这样您就可以避免 branch/trunk 手动签出、导出、移动和提交文件的不必要麻烦。


或者你也可以这样做

  1. 导航到原始 text.jsp 所在的目录(主干版本)
  2. 导出 "new" 文件 svn export https://mybranch/text.jsp
  3. 因为您的 "new" 文件的名称与您存储库中的名称相同 svn 会自动检测为修改。所以你只是 需要用 svn ci text.jsp
  4. 提交