Svn 简明教程
SVN - Perform Changes
Jerry 检出了存储库的最新版本,并开始了一个项目。他在 trunk 目录中创建了 array.c 文件。
Jerry checks out the latest version of the repository and starts working on a project. He creates array.c file inside the trunk directory.
[jerry@CentOS ~]$ cd project_repo/trunk/
[jerry@CentOS trunk]$ cat array.c
上述命令将产生以下结果。
The above command will produce the following result.
#include <stdio.h>
#define MAX 16
int main(void) {
int i, n, arr[MAX];
printf("Enter the total number of elements: ");
scanf("%d", &n);
printf("Enter the elements\n");
for (i = 0; i < n; ++i) scanf("%d", &arr[i]);
printf("Array has following elements\n");
for (i = 0; i < n; ++i) printf("|%d| ", arr[i]);
printf("\n");
return 0;
}
他在提交前想要测试他的代码。
He wants to test his code before commit.
[jerry@CentOS trunk]$ make array
cc array.c -o array
[jerry@CentOS trunk]$ ./array
Enter the total number of elements: 5
Enter the elements
1
2
3
4
5
Array has following elements
|1| |2| |3| |4| |5|
他已经编译并测试了他的代码,一切按预期工作,现在是时候提交更改了。
He compiled and tested his code and everything is working as expected, now it is time to commit changes.
[jerry@CentOS trunk]$ svn status
? array.c
? array
Subversion 在文件名之前显示“?”,因为不知道如何处理这些文件。
Subversion is showing '?' in front of filenames because it doesn’t know what to do with these files.
在提交之前,Jerry 需要将此文件添加到挂起的变更列表中。
Before commit, Jerry needs to add this file to the pending change-list.
[jerry@CentOS trunk]$ svn add array.c
A array.c
让我们使用“status”操作进行检查。Subversion 在 array.c 之前显示 A ,即该文件已成功添加到挂起的变更列表中。
Let us check it with the 'status' operation. Subversion shows A before array.c, it means, the file is successfully added to the pending change-list.
[jerry@CentOS trunk]$ svn status
? array
A array.c
若要将 array.c 文件存储到代码库中,请使用带有 -m 选项和后续提交消息的 commit 命令。如果省略 -m 选项,Subversion 会调出文本编辑器,您可以在其中键入多行消息。
To store array.c file to the repository, use the commit command with -m option followed by commit message. If you omit -m option Subversion will bring up the text editor where you can type a multi-line message.
[jerry@CentOS trunk]$ svn commit -m "Initial commit"
Adding trunk/array.c
Transmitting file data .
Committed revision 2.
现在,array.c 文件已成功添加到代码库中,并且版本号增加了 1。
Now array.c file is successfully added to the repository, and the revision number is incremented by one.