SVN将根向上移动一级

  • 本文关键字:一级 移动 SVN svn
  • 更新时间 :
  • 英文 :


我有这样的项目

project_dir
└── htdocs

SVN 签出是在 htdocs 目录上执行的,所以这是我有这个 svn 信息的根目录

工作副本根路径:/home/user/project_dir/htdocs网址: svn://mydomain.com/something

现在我想将 SVN 根从 htdocs 更改为一个级别,所以我以根身份签出到 project_dir,而不是 htdocs。

有没有一些简单的方法可以做到这一点并保持 htdocs 中的所有文件完好无损(我也有一些被忽略和不受版本控制的文件..) ?

我试图在htdocs dir中执行此操作:

svn switch --relocate svn://mydomain.com/something svn://mydomain.com/something/htdocs

但这不起作用,BC这个错误

svn: E195009: 'svn://mydomain.com/something/htdocs' is not the root of the repository

知道如何解决这个问题吗?

您是在谈论重组存储库结构还是工作副本?

尽管有可能,但我会对重组存储库非常犹豫。但是,从您的某些陈述来看,听起来您想重组您的工作目录。在 Subversion 1.6 及更低版本中,这相当简单,因为工作目录树中的每个目录都有一个用于该目录级别的完整.svn目录。砍掉不会造成任何问题。

但是,在 Subversion 1.7 中,工作目录的布局发生了变化。根目录中只有一个.svn目录,它适用于整个工作目录。砍掉根会破坏你的工作副本。

但是,您要解决的问题是什么?如果仅在子目录树htdocs进行更改,则可以在该级别提交。当你进行提交时,你正在工作的目录树是什么样子没有丝毫区别。提交历史记录将相同。

如果问题是磁盘空间,请使用 --set-depth 从工作目录中删除所有其他项目。或者,咬紧牙关,对htdoc的目录进行新的检查:

$ svn co svn://mydomain.com/something/htdocs

relocate命令在移动服务器本身时使用。例如,我最近重新配置了我的Apache httpd服务器,以从这里移动我的存储库URL:

http://svn.server.com/svn/CorporateServerTRD/trunk/...

http://svn.server.com/trd/trunk/...

这就是svn relocate出现的地方。这样,您可以将存储库移动到其他服务器,或者从http://切换到svn://,反之亦然,用户就不必重做结帐。svn relocate命令速度很快,因为只有一小段信息必须更改。

还有另一个命令svn switch(在早期版本中也是relocation命令),可以将您的工作副本从一个URL切换到另一个URL:

$ svn co svn://mydomain.com/something/trunk/htdocs

哎 呦。。。我应该在 3.2 分支上完成我的工作:

$ svn switch svn://mydomain.com/something/branches/3.2/htdocs

您可以在工作目录上尝试,但它肯定不会比新结帐更快。

如果你真的,

真的想重组你的仓库,最简单的方法是创建一个工作目录:

# First, checkout the repository root with the first level of directories in it
$ svn co --set-depth=immediates $REPO_ROOT
# Now let's get all of the directories and files immediately under htdocs
$ svn up --set-depth=immediates htdocs
# You now want to remove everything from the root of your repo execept
# for the htdocs directory. If you're using BASH, you can do the following.
# If your on Windows, you may have to do the delete one at a time.
# shopt -s extglob
$ svn delete !(htdocs)
# Now move all the files and directories in the current `htdocs` to the
# root of the repository
$ svn mv htdocs/* ..
# Delete the now empty htdocs directory
$ svn delete htdocs
# Commit your changes
$ svn commit -m"Make 'htdocs' my new root."

现在,您的htdocs内容将成为存储库的根目录。但是,您的提交历史记录将更难遵循,合并或还原也将更加困难。这就是为什么您不会在没有充分理由的情况下盲目移动和重组存储库的原因。

什么会是一个好的理由?也许添加trunkbranchestags目录,如果你设置你的存储库没有它们。也许如果你的行李箱变得如此混乱,以至于你已经放弃了它,它的历史现在毫无意义。即使在那里,我也会犹豫不决。我宁愿合并回一个好的树干,而不是删除并将分支移动到那个地方。

我认为这不是你需要relocate。您需要签出svn://mydomain.com/something,并且您不能重新定位或切换svn://mydomain.com/something/htdocs签出来执行此操作。

您可以做的是签出svn://mydomain.com/something,删除其中的htdocs目录,然后将现有目录移动到那里。你只需要稍微移动目录,但它应该可以工作。例如:

cd /home/user
mv project_dir project_dir.bak
svn co svn://mydomain.com/something project_dir
rm -fr project_dir/htdocs
mv project_dir.bak/htdocs project_dir/
svn st project_dir

如果无法移动目录,则还有另一种方法:

cd /home/user
svn co svn://mydomain.com/something something_new
mv something_new/.svn .
svn revert -R .

最新更新