我有一个没有主干目录的 svn 存储库。
我想创建主干和分支目录,并将我的所有文件(当前在根目录中)移动到主干中。
创建主干工作正常:
macbook[601] # svn mkdir trunk
A trunk
macbook[602] # svn commit trunk
Adding trunk
Committed revision 67.
将所有内容移入后备箱失败:
macbook[604] # svn move * trunk
svn: Cannot copy path 'trunk' into its own child 'trunk/trunk'
有没有办法在不单独提供所有文件和目录名称的情况下做到这一点?
有一些线程描述了如何使用 TortoiseSVN 执行此操作,但我想知道使用 svn 命令行执行此操作的正确方法。
谢谢。
编辑 :
W. 克雷格,感谢您快速而有帮助的回答。
我确实遇到了一些并发症;也许有人可以就如何解决这些问题给我一些建议。
我从最新的所有内容开始,包括一个空的“主干”目录。我也有几个不受 SVN 管理的文件:
注意:在尝试此之前,我将一些文件移动到“notes”子目录中并成功提交了该更改。如果有帮助,我可以提供更多详细信息。
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”到主干中。
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 的响应是一长串计划添加和删除的文件。
然后我在尝试提交时失败了。
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”目录有冲突
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
我试图将“注释”更新为旧版本,但冲突不允许:
macbook[606] ~/dev/dictionary # svn up notes -r 68
C notes
At revision 68.
Summary of conflicts:
Tree conflicts: 1
然后我尝试“svn解决”冲突:
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
我想我应该恢复而不是提交预定的移动以防万一其他事情搞砸了,所以我这样做了:
macbook[630] ~/dev/dictionary # svn revert .
但是,添加和删除操作仍按计划进行。
我很感激有关如何执行以下操作的任何建议:
1)将我的本地副本带到执行“svn move list_of_dirs trunk”之前的状态
2) 确保“notes”目录是最新的并且不会干扰“svn move”
3)成功地将所有目录从我的根目录移动到“主干”
非常感谢。
最佳答案
您使用的是 MacBook,所以让我们假设您的 shell 使用 bash:
# 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
只要您的文件名中没有空格,这就会起作用。如果这样做,请改用它:
# 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 - 如何在没有主干的情况下在现有 svn repo 中创建主干目录,并将所有文件移动到新主干?,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/3067217/