如何在没有主干的情况下在现有 svn repo 中创建主干目录,并将所有文件移动到新主干? [英] How to create trunk directory in existing svn repo without a trunk, and move all files to new trunk?

查看:16
本文介绍了如何在没有主干的情况下在现有 svn repo 中创建主干目录,并将所有文件移动到新主干?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个没有主干目录的 svn 存储库.我想创建主干和分支目录,并将我的所有文件(当前在根目录中)移动到主干中.

I've got an svn repo with no trunk dir. I'd like to create the trunk and branches dirs, and move all my files (currently in the root) into trunk.

创建主干工作正常:

macbook[601]  # svn mkdir trunk
A         trunk
macbook[602]  # svn commit trunk
Adding         trunk
Committed revision 67.

将所有内容移入后备箱失败:

moving everything into trunk fails:

macbook[604] # svn move * trunk
svn: Cannot copy path 'trunk' into its own child 'trunk/trunk'

有没有办法做到这一点而无需单独提供所有文件和目录名称?有一些线程描述了如何使用 TortoiseSVN 执行此操作,但我想知道使用 svn 命令行执行此操作的正确方法.

is there a way to do this without giving it all the file and dir names individually? There are threads describing how to do this with TortoiseSVN, but i'd like to know the right way to do it with the svn commandline.

谢谢.

编辑:

W.克雷格,感谢您快速而有帮助的回答.
我确实遇到了一些并发症;也许有人可以就如何解决这些问题给我一些建议.

W. Craig, thanks for your quick and helpful answer.
I did run into some complications; perhaps someone can give me a bit of advice about how to resolve them.

我从最新的所有内容开始,包括一个空的主干"目录.我也有几个不受 SVN 管理的文件:

I started out with everything up to date, including an empty "trunk" directory. I also had several files that are not managed by SVN:

注意:在尝试此之前,我将一些文件移动到notes"子目录中并成功提交了该更改.如果有帮助,我可以提供更多详细信息.

note: Prior to attempting this, I moved some files into the "notes" subdir and successfully committed that change. I can give more details if that's helpful.

macbook[582] ~/dev/dictionary # svn stat
?       vendor/plugins/redbox_broken
?       config/database.yml
?       lib/dict.rb.original
?       public/javascripts/redbox.js.big
macbook[583] ~/dev/dictionary # ll
total 64
drwxr-xr-x   3 stupakov  stupakov    102 Jun 17 22:05 MISC
-rw-r--r--   1 stupakov  stupakov  10011 Oct 18  2009 README
-rw-r--r--   1 stupakov  stupakov    307 Oct 18  2009 Rakefile
-rw-r--r--   1 stupakov  stupakov   9514 Jun 17 22:05 TO_DO.txt
drwxr-xr-x   7 stupakov  stupakov    238 Mar 11 21:07 app
drwxr-xr-x  11 stupakov  stupakov    374 Jun  5 16:02 config
drwxr-xr-x   7 stupakov  stupakov    238 Jun 17 22:05 db
drwxr-xr-x   4 stupakov  stupakov    136 Oct 18  2009 doc
drwxr-xr-x   6 stupakov  stupakov    204 Oct 18  2009 features
drwxr-xr-x  17 stupakov  stupakov    578 Jun 17 20:51 lib
drwxr-xr-x   4 stupakov  stupakov    136 Apr  4 20:04 log
drwxr-xr-x   6 stupakov  stupakov    204 Oct 18  2009 nbproject
drwxr-xr-x   9 stupakov  stupakov    306 Jun 17 21:55 notes
drwxr-xr-x  11 stupakov  stupakov    374 Oct 18  2009 public
drwxr-xr-x  15 stupakov  stupakov    510 Oct 18  2009 script
drwxr-xr-x  13 stupakov  stupakov    442 Oct 18  2009 spec
drwxr-xr-x   7 stupakov  stupakov    238 Oct 18  2009 stories
drwxr-xr-x   9 stupakov  stupakov    306 Oct 18  2009 test
drwxr-xr-x   7 stupakov  stupakov    238 Feb 17 22:46 tmp
drwxr-xr-x   3 stupakov  stupakov    102 Jun 17 22:05 trunk
drwxr-xr-x   5 stupakov  stupakov    170 Apr  3 20:10 vendor
-rw-r--r--   1 stupakov  stupakov   1151 Sep 26  1998 whale.gif
macbook[584] ~/dev/dictionary # ll trunk

我试图将所有内容svn move"到主干中.

I attempted to "svn move" everything into trunk.

macbook[585] ~/dev/dictionary # echo $(cat ~/flist)
README Rakefile app config db doc features lib log nbproject notes public script spec stories test tmp vendor whale.gif
macbook[586] ~/dev/dictionary # svn move $(cat ~/flist) trunk

来自 SVN 的响应是一长串计划添加和删除的文件.

The response from SVN was a long list of files scheduled for addition and deletion.

然后我在尝试提交时失败了.

I then got a failure when trying to commit this.

macbook[589] ~/dev/dictionary # svn commit -m "moving everything to trunk subdir"
Deleting       README
Deleting       Rakefile
Deleting       app
Deleting       config
Deleting       db
Deleting       doc
Deleting       features
Deleting       lib
Deleting       log
Deleting       nbproject
Deleting       notes
svn: Commit failed (details follow):
svn: Item '/dictionary/notes' is out of date

现在notes"目录有冲突

And now the "notes" dir has a conflict

macbook[597] ~/dev/dictionary # svn stat notes
D     C notes
      >   local delete, incoming edit upon update
D       notes/HACKATHON
D       notes/newsgroup_questions.txt
D       notes/svn_rails.sh
D       notes/mysql_notes.txt
D       notes/HOW
D       notes/css_notes.txt

我尝试将注释"更新为旧版本,但冲突不允许:

I attempted to update "notes" to an older revision, but the conflict did not allow that:

macbook[606] ~/dev/dictionary # svn up notes -r 68
   C notes
At revision 68.
Summary of conflicts:
  Tree conflicts: 1

然后我尝试svn解决"冲突:

Then I attempted to "svn resolve" the conflict:

macbook[612] ~/dev/dictionary # svn resolve --accept=working notes
Resolved conflicted state of 'notes'
macbook[613] ~/dev/dictionary # ll notes
macbook[614] ~/dev/dictionary # svn stat notes -v
D               68       70 stupakov     notes
D               70       70 stupakov     notes/HACKATHON
D               70       70 stupakov     notes/newsgroup_questions.txt
D               70       70 stupakov     notes/svn_rails.sh
D               70       70 stupakov     notes/mysql_notes.txt
D               70       70 stupakov     notes/HOW
D               70       29 stupakov     notes/css_notes.txt

我想我应该恢复而不是提交预定的移动以防万一其他事情搞砸了,所以我这样做了:

I figured I should revert rather than committing the scheduled move in case something else was messed up, so I did this:

macbook[630] ~/dev/dictionary # svn revert .

但是,添加和删除仍然是预定的.

However, the adds and deletes are still scheduled.

对于如何执行以下操作的任何建议,我将不胜感激:

1) 将我的本地副本恢复到执行svn move list_of_dirs trunk"之前的状态

1) Bring my local copy to the state it was in before doing "svn move list_of_dirs trunk"

2) 确保notes"目录是最新的并且不会干扰svn move"

2) Ensure that the "notes" dir is up to date and does not interfere with the "svn move"

3) 成功地将所有目录从我的根目录移动到主干"

3) Successfully move all dirs from my root dir into "trunk"

非常感谢.

推荐答案

您使用的是 MacBook,所以让我们假设您的 shell 使用 bash:

You're using a MacBook, so let's assume bash for your shell:

# Select all the relevant files/directories (less trunk, branches, and tags)
ls * | egrep -v "trunk|branches|tags" > /tmp/files

# Move them within the repository
svn move $(cat /tmp/files) trunk

只要您的文件名中没有空格,这将起作用.如果这样做,请改用它:

This will work as long as you don't have spaces in your file names. If you do, then use this instead:

# Select all the relevant files/directories (less trunk, branches, and tags)
ls * | egrep -v "trunk|branches|tags" > /tmp/files

# Move them within the repository
cat /tmp/files | while read file ; do
    svn move "${file}" trunk
done

这篇关于如何在没有主干的情况下在现有 svn repo 中创建主干目录,并将所有文件移动到新主干?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆