svn 仓库设置

发布于 2024-11-16 22:10:59 字数 277 浏览 3 评论 0原文

我正在尝试在 FreeBSD 系统上为我的课程项目设置一个存储库。代码在~/OSI中,然后我输入以下命令:

   % svnadmin create ///home/SVN/repo
   % svn co file:///home/SVN/repo
   % cd ~/OSI
   % chmod -R u+w include
   % svn add include

然后出现错误“.”不是工作副本。我必须先将 ~/OSI 导入到 /home/SVN/repo 吗?

I'm trying to set up a repository on a FreeBSD system for my course project. The code is in ~/OSI, then I typed the following commands:

   % svnadmin create ///home/SVN/repo
   % svn co file:///home/SVN/repo
   % cd ~/OSI
   % chmod -R u+w include
   % svn add include

Then an error "." is not a working copy. Do I have to import ~/OSI to /home/SVN/repo first?

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

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

发布评论

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

评论(3

感情旳空白 2024-11-23 22:10:59
% svnadmin create ///home/SVN/repo
% svn co file:///home/SVN/repo
% cd ~/OSI

您对 Subversion 存储库目录和工作目录之间的差异感到完全困惑。我教授 Subversion 很长时间了,这是最常见的事情。您不能使用 Subversion 存储库作为工作目录。您必须重新开始,因为您可能已经损坏了存储库结构。


一次一步。

  • 您的存储库是 Subversion 服务器 存储存储库中所有文件的所有版本的位置。你不碰。您甚至可能不知道它在哪里,甚至可能不在您的本地计算机上。
  • 您的工作目录包含存储库特定修订版的副本。这是通过 Subversion 客户端 完成的。这是您执行所有操作的地方,它位于本地计算机上,通常位于 $HOME 下的目录中。

因此,首先您需要创建一个存储库。为此,您可以使用 svnadmin 命令。该命令对存储库进行操作。该命令是:

$ svnadmin create <directoryName>

请注意,该命令中没有 URL。事实上,svnadmin 从不采用 URL,只采用位于本地计算机上的物理文件。 svnlook 命令也是如此。这些在服务器上运行。在你的情况下,你想要这样做:

$ rm -rf /home/SVN/repo    #Remove the old copy if its still there.
$ svnadmin create /home/SVN/repo

前面只需要一个斜线。这是一个目录的名称。您也可以这样做:

$ cd /home/SVN
$ svnadmin create repo

甚至可以这样做:

$ svnadmin create ~SVN/repo   #Hope you have write access in this dir!

我强烈建议您使用 svnserve 作为您的 Subversion 存储库服务器。这使得输入 URL 变得更加容易。另外,它还有助于将您与存储库位置分开。初学者会发现它不那么令人困惑。

为此,您需要执行两件事:

  1. 编辑 /home/SVN/conf/svnserve.conf 文件。
  2. 创建 /hone/SVN/conf/passwd 文件。

首先,编辑 svnserve.conf 文件。您需要修改两行:

将有两行(在我的文件版本中为 11 和 12)如下所示:

# anon-access = read
# auth-accesss = write

删除前面的 # 。事实上,这是默认的,所以这并不重要。如果这是您的个人存储库,您可以将 anon-access 更改为 write。这样,您就不需要登录。我个人都保持原样。

第 20 行周围是这样的:

# password-db = passwd

再次删除该行前面的 #。就是这样。保存此文件。

现在,在同一目录中,编辑 passwd 文件。在 [Users] 行下输入如下内容:

 david = swordfish

david 是您的用户 ID。我建议您将其设置为与您的 Unix ID 相同的 ID。 swordfish 是密码。随心所欲地做吧。如果您希望其他人能够访问此存储库,只需将它们放在这里,每行一个用户,格式与您的用户名和密码相同。保存 passwd 文件。您永远不必再接触这些文件。

现在,我们将启动svnserve。每当您重新启动系统时都需要执行此操作。您甚至可能想将启动脚本放在 /etc/init.d 目录下:(

$ svnserve -r /home/SVN/repo -d

一个小细节...确保运行 svnserve 的用户拥有该目录以及 下的所有文件>/home/SVN/repo 否则,svnserve 命令将无法读取/写入所需的文件,因为您正在您的目录下执行所有这些操作。 用户 ID,应该没问题)。

就是这样,现在您可以转到其他地方并创建一个工作目录。在您的主目录下执行此操作。假装 /home/SVN/repo 根本不存在。

 $ cd $HOME
 $ svn co svn://localhost my_workdir
 $ cd my_workdir
 $ svn mkdir trunk tags branches     #Why the hell not?
 $ svn commit -m "Made the basic directory layout"

在此过程中,它可能会要求您输入密码。只需输入您在 passwd 文件中使用的相同密码即可。您刚刚所做的是创建您的第一个提交。您创建了三个基本目录 trunkbranchestags。你需要这样做吗?没有。

请注意,您的目录位于 ~/my_workdir 中,而不是位于 /home/SVN/repo 中。请注意,因为我使用的是 svnserve,所以我什至没有提及该目录。 /home/SVN/repo 是服务器的目录。你别碰!正如我所说,作为客户,很有可能您甚至不知道它位于哪里。

现在,你的进口:

 $ cd trunk
 $ cp ~/OSI .
 $ svn add -R OSI

哇!没有svn import?不,我们有一个工作目录 (~/my_workdir),所以我们可以简单地添加文件。 Subversion svn add 命令将递归添加 OSI 目录以及所有文件和子目录。您可以运行 svn status 命令并验证是否已添加所有文件。

现在,您所要做的就是提交更改:

 $ svn commit -m"Added in OSI files"

请注意,我仅需要 svn://localhost 命令用于 svn co 命令。我的工作目录已经知道从中签出的 URL。您可以运行 svn info 并查看该信息。

现在,试试这个:

 $ cd ~
 $ rm -rf my_workdir

我们已经完全删除了您刚刚所做的所有工作。然而,Subversion 存储库仍然拥有它。让我们再次检查一下:

 $ svn co svn:/localhost/trunk/OSI

这将创建一个 OSI 目录,其中包含您导入到 Subversion 存储库中的所有 OSI。这是您的新工作目录。请注意,我指定了 trunk/OSI。现在,您可以在那里完成所有工作,并提交所有更改。

我希望这有助于为您澄清问题。现在,阅读在线Subversion 用户指南。现在您已经完成了此操作,您会发现开始的章节变得更有意义。

% svnadmin create ///home/SVN/repo
% svn co file:///home/SVN/repo
% cd ~/OSI

You're completely confused by the difference between the Subversion Repository Directory, and your working directory. I've been teaching Subversion for a long time, and this is the most common thing that happens. You cannot use the Subversion repository as your working directory. You'll have to start over because you've probably damaged the repository structure.


One step at a time.

  • Your repository is where the Subversion Server stores all versions of all the files in your repository. You don't touch. You might not even know where this is, and it might not even be on your local machine.
  • Your working directory contains a copy of a particular revision of the repository. This is done through the Subversion Client. This is where you do everything, and it's located on your local machine, usually in a directory under your $HOME.

So, first you need to create a repository. You use the svnadmin command for that. That command does stuff to the repository. The command is:

$ svnadmin create <directoryName>

Notice there's no URL in the command. In fact the svnadmin never takes a URL, only a physical file located on the local machine. Same is true with the svnlook command. These run on the server. In your case, you want to do this:

$ rm -rf /home/SVN/repo    #Remove the old copy if its still there.
$ svnadmin create /home/SVN/repo

Only a single slash is needed in the front. This is the name of a directory. You could have also done this:

$ cd /home/SVN
$ svnadmin create repo

And maybe even this:

$ svnadmin create ~SVN/repo   #Hope you have write access in this dir!

I highly recommend that you use the svnserve as your Subversion repository server. This makes it easier to type in URLs. Plus, it helps separate yourself from the repository location. Beginners find it less confusing.

To do this, you need to do two things:

  1. Edit the /home/SVN/conf/svnserve.conf file.
  2. Create a /hone/SVN/conf/passwd file.

First, editing the svnserve.conf file. You'll need to modify two lines:

There will be two lines (11 and 12 in my version of the file) that look like this:

# anon-access = read
# auth-accesss = write

Remove the # from in front. Actually, this is the default, so it really doesn't matter. If this is your personal repo, you can change anon-access to write. That way, you don't need to log in. I personally keep them both the way they are.

Around line #20 is this:

# password-db = passwd

Again, remove the # from the front of the line. That's it. Save this file.

Now, in the same directory, edit the passwd file. Under the [Users] line put something like this:

 david = swordfish

The david is your User ID. I suggest that you make it the same ID as your Unix ID. The swordfish is the password. Make it whatever you want. If you want others to be able to access this repository, simply put them in here, one user per line, in the same format as your user name and password. Save the passwd file. You'll never have to touch these files again.

Now, we'll start the svnserve. You'll need to do this whenever you restart your system. You might even want to put a startup script under your /etc/init.d directory:

$ svnserve -r /home/SVN/repo -d

(One little detail... Make sure that the user running svnserve owns the directory and all the files under /home/SVN/repo. Otherwise, the svnserve command won't be able to read/write the required files. Since you're doing all of this under your user ID, that should be fine).

That's it, now you can go elsewhere and create a working directory. Do this under YOUR HOME directory. Pretend that /home/SVN/repo doesn't even exist.

 $ cd $HOME
 $ svn co svn://localhost my_workdir
 $ cd my_workdir
 $ svn mkdir trunk tags branches     #Why the hell not?
 $ svn commit -m "Made the basic directory layout"

Somewhere along the line, it might ask for your password. Just put in the same one you used in the passwd file. What you've just done is create your first commit. You created the three base directories trunk, branches, and tags. Did you need to do this? Nope.

Notice that your in the ~/my_workdir and not in /home/SVN/repo. Notice, because I'm using svnserve, I didn't even mention that directory. The /home/SVN/repo is the Server's directory. You don't touch! As I said, it's very possible -- as a client -- you don't even know where it's located.

Now, your import:

 $ cd trunk
 $ cp ~/OSI .
 $ svn add -R OSI

Whoa! No svn import? Nope, we have a working directory (~/my_workdir), so we can simply add the files. The Subversion svn add command will recursively add in the OSI directory and all files and sub directories. You can run the svn status command and verify that all the files were added.

Now, all you have to do is submit your changes:

 $ svn commit -m"Added in OSI files"

Notice that I needed the URL svn://localhost only for the svn co command. My working directory already knows the URL it was checked out from. You can run svn info and see that information.

Now, try this:

 $ cd ~
 $ rm -rf my_workdir

We have completely removed all the work you just did. However, the Subversion repository still has it. Let's check it out again:

 $ svn co svn:/localhost/trunk/OSI

This will create an OSI directory with all of your OSI you've imported into your Subversion repository right there. This is your new working directory. Notice that I specified trunk/OSI. Now, you can do all of your work there, and commit all of your changes.

I hope this helps clarifies things for you. Now, read the on line Subversion User Guide. Now that you've done this, you'll find the beginning chapters making a lot more sense.

耳根太软 2024-11-23 22:10:59

你的问题的答案是“是”,你需要先将 ~/OSI 导入到 /home/SVN/repo 。

将该文件夹导入到 SVN 存储库后,您可以删除 OSI 目录并从存储库中签出新的工作区,然后继续下一步。

% svn import ~/OSI file://home/SVN/repo/trunk
% rm -rf ~/OSI
% svn co file://home/SVN/repo/trunk/OSI
% cd ~/OSI

The answer to your question is "Yes", you need to import ~/OSI to /home/SVN/repo first.

After you import that folder into SVN repository, then you can blow away your OSI directory and checkout a fresh workspace from the repository and continue with your next step.

% svn import ~/OSI file://home/SVN/repo/trunk
% rm -rf ~/OSI
% svn co file://home/SVN/repo/trunk/OSI
% cd ~/OSI
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文