欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页

svn 回复和常用命令

程序员文章站 2022-07-13 10:32:18
...
1.还原到某个版本

svn up -r 版本号
svn up -r 版本号 文件名称

2. 还原改动

对应提交(commit),要有类似回滚(rollback)的操作。

svn revert file_path

或者通过tortoiseSVN,eclipse插件。

这个操作对开发人员十分有用,在改动被人很多代码后可以“一键恢复”。

3. “还原”已提交的改动

revert只适合未提交的情况。

如果已经提交,发现问题,要回退到之前的修订版。

首先需要:
svn up

让本地工作拷贝更新到最新状态。

然后:
svn log your_file_path

查看文件日志,这时候提交时填写的说明信息就派上用场了。

查看两个修订版之间的不同:

svn diff -r 旧修订版序号:新修订版序号 your_file_path

或者通过tortoiseSVN,eclipse插件。

决定用哪个旧的修订版号后,用旧的修订版号文件覆盖新的修订版号文件。

svn merge -r 新修订版序号:旧修订版序号 your_file_path

还需要:
svn commit -m “恢复到某修订版(某修订版作废)”

这个还原是所谓的,不是用旧的版本号替代,而是将旧文件覆盖新文件。

常用命令:
svnadmin create your_project_folder 建立文件库

mkdir you -p 创建文件夹

svn import path_to_existing_files file://full_path_to_project_folder/trunk/ -m "Initial import" 导入文件

pwd 查看当前路径

svn update 更新

ls -a 简短列出目录下全部文件

svn commit button.c 提交单个文件

svn status 查看当前目录svn中的全部文件状态

svn status (also known as stat, st)
Print the status of working copy files and directories.
svn status path...
With no args, print only locally modified items (no network access).
With -u, add working revision and server out-of-date information.
With -v, print full revision information on every item.
The first five columns in the output are each one character wide.
First column: Says if item was added, deleted, or otherwise changed.
“ ” No modifications.
A Added.
C Conflicted.
D Deleted.
G Merged.
I Ignored.
M Modified.
R Replaced.
X Item is unversioned, but is used by an externals definition.
? Item is not under version control.
! Item is missing (removed by non-svn command) or incomplete.
˜ Versioned item obstructed by some item of a different kind.
Second column: Modifications of a file’s or directory’s properties.
“ ” No modifications.
C Conflicted.
M Modified.
Third column: Whether the working copy directory is locked.
“ ” Not locked.
L Locked.
Prepared exclusively

Fourth column: Scheduled commit will contain addition with history.
“ ” No history scheduled with commit.
+ History scheduled with commit.
Fifth column: Whether the item is switched relative to its parent.
“ ” Normal.
S Switched.
The out-of-date information appears in the eighth column (with -u).
* A newer revision exists on the server.
“ ” The working copy is up-to-date.
The remaining fields are variable width and delimited by spaces: the
working revision (with -u or -v), the last-committed revision, and lastcommitted
author (with -v). The working copy path is always the final
field, so it can include spaces.