Using command-line Subversion to access project source files
- About source code version control with Software Configuration Management (Subversion)
- Using command-line svn to access project source files
Getting started with command-line Subversion
If you are participating in a development project that is using Subversion for version control, you will need to use Subversion to access and change project source files. You can browse the source code online to view a project's directory structure and files by clicking on the Subversion link in the left navigation pane for the project.
The Subversion page displays with three subdirectories: branches/, tags/, trunk/ and one README file. The README file gives a top level view of the Subversion repository. You can click Access options to view the Subversion client setup instructions. You must have a Subversion client installed on your local machine.
Getting a local working copy for your project: svn checkout
To get a "working copy" of the latest source files, you must check out the source files, a process which copies the files onto your system from the repository. In your shell or terminal client, type:
svn checkout https://(projectname).(domain)/svn/(projectname)/(DIR) (projectname) --username [type-user-name-here]
Enter your user password when prompted. This should be the same password associated with your user account on this site. Not specifying the directory will checkout the entire project source code. You may want to checkout the 'trunk/' directory as it has the working 'www/' folder.
Switches: --revision (-r) REV, --quiet (-q), --non-recursive (-N), --username USER, --password PASS, --no-auth-cache, --non-interactive, --config-dir DIR
See Basic Work Cycle, Initial Checkout, Working Copies
Note: If your site is not SSL (Secured Socket Layer) enabled, use http
instead of https
to perform a Subversion operation. For example, to checkout the latest source code from a project's repository, use this command:
svn checkout https://(projectname).(domain)/svn/(projectname)/(DIR) (projectname) --username [type-user-name-here]
Working with files in the Subversion repository
Once you have checked out a local copy of the project repository, you can edit the existing files, create new files and directories, and delete files locally. Any changes you make affect only your local copies of the project files until you commit your changes back to the Subversion repository.
Adding files/directories from your working copy to the repository: svn add
You can add a new file to the repository after you have first created and edited it in your working directory or add a directory with or without it's contents using
svn add FILENAME/DIR
.
This will add files/directories to your working copy and schedule them for addition to the repository. They will be uploaded and added to the repository on your next commit. If you add something and change your mind before committing, you can unschedule the addition using svn revert
.
Switches: --targets FILENAME, --non-recursive (-N), --quiet (-q), --config-dir arg, --auto-props, --no-auto-props
See Examples on adding files/directories
Viewing the content of specific files with revision and author information: svn blame
You can view the author and revision information in-line for the specified files by typing:
svn blame FILENAME
Each line of text is annotated at the beginning with the author (username) and the revision number for the last change to that line.
Switches: --revision (-r) REV, --username USER, --password PASS, --no-auth-cache, --non-interactive, --config-dir DIR
Viewing the content of specific files: svn cat
At times, your working copy may be obsolete as compared to the repository or you may have modified your local working copy. In such cases, you will want to see the differences in the content of a specific file before you commit your changes or decide edit your working copy. Running svn cat FILENAME
will automatically fetch the HEAD revision from the repository. This subcommand is mainly used to retrieve a file as it existed in an older revision number and display it on your screen. Alternatively, you can browse the source code of your project on this site to do the same.
Switches: --revision (-r) REV, --username USER, --password PASS, --no-auth-cache, --non-interactive, --config-dir DIR
Cleaning up the working copy: svn cleanup
Sometimes, you may get a "working copy locked" error. To remove the locks and recursively clean up the working copy, use svn update
.
Switches: --diff3-cmd CMD, --config-dir DIR
See svn cleanup
Copying file or directory in a working copy or in the repository: svn copy
Your project may require you to make use of legacy documents. For example, you may want to use an already existing HTML file and use its code as reference to maintain the look and feel of the product while creating fresh content. Instead of creating a file from scratch, you can simply copy this file using svn copy
, save it under a different name and change the content. You can copy a file from the repository to your local working copy or vice versa. You can also copy files from within your local working copy. Subversion does not support cross repository copying. Use svn copy SRC DST
to achieve this.
Switches: --message (-m) TEXT, --file (-F) FILE, --revision (-r) REV, --quiet (-q), --username USER, --password PASS, --no-auth-cache, --non-interactive, --force-log, --editor-cmd EDITOR, --encoding ENC, --config-dir DIR
See svn copy
Deleting a file or a directory from your local working copy: svn delete
You may want to delete unwanted files from your local working copy. Using svn delete FILENAME
schedules it to be deleted. The actual deletion of the file in the repository takes place only when you commit.
Switches: --force, --force-log, --message (-m) TEXT, --file (-F) FILE, --quiet (-q), --targets FILENAME, --username USER, --password PASS, --no-auth-cache, --non-interactive, --editor-cmd EDITOR, --encoding ENC, --config-dir DIR
Viewing the differences between files: svn diff
You can use svn diff
to display local modifications in a specified file in your working copy against the one in the repository. In the command prompt, type:
svn diff (PATH of the file) (URL of the project's repository)
For example, to compare a locally modified file "index.html" against the one in the project's repository, type:
svn diff $SRC/...../index.html https://(projectname).(domain)/svn/(projectname)/trunk (projectname) --username [type-user-name-here]
Alternatively, you can go to the directory where the file belongs and type:
svn diff (FILENAME)
This will display the difference with the revision number.
Switches: --revision (-r) REV, --old OLD-TARGET, --new NEW-TARGET, --extensions (-x) "ARGS", --non-recursive (-N), --diff-cmd CMD, --notice-ancestry, --username USER, --password PASS, --no-auth-cache, --non-interactive, --no-diff-deleted, --config-dir DIR
See Examining History, svn diff
Exporting a clean directory tree on your local machine: svn export
You can extract an unversioned copy, that is, a clean directory of a tree, on your local machine from the project repository or from within your local working copy. To get a clean directory of an older revision from the repository, type:
svn export [-r REV] [PATH]
This will export a clean directory tree from the repository specified by URL, at a revision REV (if specified), otherwise at HEAD, into PATH. If PATH is omitted, the last component of the URL is used for the local directory name. Alternatively, you can also export a clean directory tree from the working copy specified by PATH1 into PATH2 within your local machine. This will preserve all local changes, but will not copy files under version control. To achieve this, type:
svn export PATH1 PATH2
Switches: --revision (-r) REV, --quiet (-q), --force, --username USER, --password PASS, --no-auth-cache, --non-interactive, --config-dir DIR
Getting help on subversion: svn help
Subversion offers you help within the command-line interface. To get help on a specific subcommand, type:
svn help [SUBCOMMAND...]
Switches: --version, --quiet (-q)
Contributing your changes to the SVN repository
After making changes to files and/or directories locally, you must commit those changes to the SVN repository.
Committing your changes: svn commit
To commit your changes into the shared repository, type:
svn commit -m "Type your justification here"
If you do not include a description of your change to the file, you will be prompted to add it by invoking your file editor before svn can complete the commit action or you will get a "Commit failed" error. All commits are logged automatically and posted to the project's commits discussion.
Switches: --message (-m) TEXT, --file (-F) FILE, --quiet (-q), --non-recursive (-N), --targets FILENAME, --force-log, --username USER, --password PASS, --no-auth-cache, --non-interactive, --encoding ENC, --config-dir DIR
See Commit Your Changes, editor-cmd
Importing an unversioned file or tree in the project repository: svn import
You can recursively commit an unversioned file or tree into the project repository using svn import
. Parent directories are created in the repository as required. The following command will recursively commit a copy from the PATH to the URL. If PATH is omitted "." is assumed.
svn import [PATH] URL
Example: To create an unversioned directory (D) with a file on your local machine. Navigate to your Subversion page by clicking the Subversion link in the left navigation pane for your project. Note that NEWDIR is not listed under Browse source code. To import D into your project's repository, type:
svn import -m "Type your message here" D http://(projectname).(domain)/svn/(projectname)/NEWDIR
Refresh the page. Note that D is listed under Browse source code. Click D to see the file.
Switches: --message (-m) TEXT, --file (-F) FILE, --quiet (-q), --non-recursive (-N), --username USER, --password PASS, --no-auth-cache, --non-interactive, --force-log, --editor-cmd EDITOR, --encoding ENC, --config-dir DIR, --auto-props, --no-auto-props
Printing information about paths in your working copy: svn info
You will from time to time need specific information about files in your working copy to execute certain subcommands. Typing svn info
will print exhaustive but useful information about items in your working copy paths in your working copy, including: Path, Name, URL, Revision, Node Kind, Last Changed, author, Last Changed Revision, Last Changed Date, Text Last Updated, Properties Last Updated and Checksum.
Switches: --targets FILENAME, --recursive (-R), --config-dir DIR
Viewing list of directory entries in the repository: svn list
Before starting work on a project or fetching a 'working copy', you may want to see the contents i.e. directories and files in your project's repository or view directory entries in your local working copy. You can type svn list [TARGET...]
in the command prompt to view the same. Alternatively, you can view your project's repository by navigating to the Software configuration management page within your project.
Switches: --revision (-r) REV, --verbose (-v), --recursive (-R), --username USER, --password PASS, --no-auth-cache, --non-interactive, --config-dir DIR
Viewing commit log messages: svn log
You can view the individual file/directory histories of the files/directories in your 'working copy' or the repository to track revision information by typing:
svn log [PATH]
The result is a display of the file's/directories' revision information, starting with the most current revision with information such as the commit messages and the author name. Alternatively, you can use this site to view the commit log messages for individual files in your project repository. Click the Subversion link from the left navigation pane of your project. The Subversion page appears. Search for your file inside the directories underBrowse source code and click the filename. This will display a page with commit log messages.
Switches: --revision (-r) REV, --quiet (-q), --verbose (-v), --targets FILENAME, --stop-on-copy, --incremental, --xml, --username USER, --password PASS, --no-auth-cache, --non-interactive, --config-dir DIR
See svn log
Merging changes: svn merge
You can run the svn merge
command to tell Subversion to merge the latest versions of files from the repository into your working copies.
Switches: --revision (-r) REV, --non-recursive (-N), --quiet (-q), --force, --dry-run, --diff3-cmd CMD, --ignore-ancestry, --username USER, --password PASS, --no-auth-cache, --non-interactive, --config-dir DIR
See svn merge
, Resolve Conflicts (Merging Others' Changes), Branching and Merging: Common Use-Cases for Merging, Best Practices for Merging
Working with the repository
Creating new directory: svn mkdir
To create a new directory in your working copy, type:
svn mkdir PATH
To create a new directory in your project repository, type:
svn mkdir URL
The final component of the PATH or URL determines the directory name. A directory in the repository is created with an immediate commit, so it requires a commit message
Switches: --message (-m) TEXT, --file (-F) FILE, --quiet (-q), --username USER, --password PASS, --no-auth-cache, --non-interactive, --editor-cmd EDITOR, --encoding ENC, --force-log, --config-dir DIR
Moving a file or a directory: svn move
You can move a file or a directory within your working copy or within your project's repository using svn move SRC DST
. This command is equivalent to an svn copy
followed by svn delete
. Moving a file or a directory within your working copy moves and schedules it for addition for the next commit. Moving a file or a directory within your project repository is an atomic commit, so it requires a commit message.
Switches: --message (-m) TEXT, --file (-F) FILE, --revision (-r) REV, --quiet (-q), --force, --username USER, --password PASS, --no-auth-cache, --non-interactive, --editor-cmd EDITOR, --encoding ENC, --force-log, --config-dir DIR
Working with properties
Subversion has a number of specific properties that affect or determine it's behavior. You can modify, commit, and revert property changes just like the contents of your files. You can delete, edit, print, list, set a property from files, directories or revisions from your local working copy or your project's repository.
See Properties, Unversioned Properties, Meta-data Properties, svn propdel
, svn propedit
, svn propget
, svn proplist
, svn propset
, Hook Scripts
Resolving conflicts: svn resolved
You may get a conflict while updating your local working copy. You will need to resolve the conflict. After resolving, type svn resolved PATH...
. to tell your working copy that the conflict has been "resolved."
Switches: --targets FILENAME, --recursive (-R), --quiet (-q), --config-dir DIR
See Resolve Conflicts (Merging Others' Changes)
Reverting your changes: svn revert
As you work with Subversion, you will realize that svn revert PATH...
is equivalent to a Ctrl Z
on Windows. You can:
- Revert any local changes on your local working copy and thus, resolve any conflicted states.
- Revert the contents of an item and the property changes in your working copy.
- Cancel out any scheduling operations like file addition, file deletion etc.
NOTE that not providing any target may result in loss of changes in your working copy.
Switches: --targets FILENAME, --recursive (-R), --quiet (-q), --config-dir DIR
Getting status of files/directories: svn status
It is a good practice in version control to review your changes before committing them to the project's repository. You can run svn status
to print the status of the files and directories in your working copy. This will result in a coded eight column output. It is humanly impossible to draw an 'error-free' conclusion from the output as each column has an exhaustive legend. To make this task simpler and simultaneously see an example, typesvn help status
in your command prompt.
Switches: --show-updates (-u), --verbose (-v), --non-recursive (-N), --quiet (-q), --no-ignore, --username USER, --password PASS, --no-auth-cache, --non-interactive, --config-dir
Switching your working copy: svn switch
You can update your working copy to mirror a new URL using svn switch URL [PATH]
. You can move a working copy or a part of your working copy to a new branch. You can use this subcommand as a shortcut for branching.
Switches: --revision (-r) REV, --non-recursive (-N), --quiet (-q), --diff3-cmd CMD, --relocate, --username USER, --password PASS, --no-auth-cache, --non-interactive, --config-dir DIR
See Switching a Working Copy, Branching and Merging and svn switch
Updating your working copy: svn update
As a good version control practice, it is recommended that you update your local working copy with the project repository everyday using:
svn update [PATH...]
The updated items listed with their current status indicated as follows:
- A = A file was added to your working copy.
- U = A file was updated to your working copy.
- D = A file was deleted from your working copy.
- R = A file was replaced in your working copy.
- G = A file was successfully merged.
- C = A file has merge conflicts that must be resolved by hand
Switches: --revision (-r) REV, --non-recursive (-N), --quiet (-q), --diff3-cmd CMD, --username USER, --password PASS, --no-auth-cache, --non-interactive, --config-dir DIR
See Update Your Working Copy, Merging Conflicts By Hand
Branching and tagging
A project's trunk is usually used for the main line of development whereas branches are usually used for variations on that line. A branch is an ongoing line of development. In a Software Development Life Cycle, branches are often used when a public release of a software product is due, to allow testers to work on the release candidate so that new development can go on independently of the testing. Branches are also used for experimental work and a complete code rewrite. Tagging is a way of marking a group of file revisions as belonging together. Though branches and tags are created using the svn copy
subcommand, branches and tags are different things. A branch represents multiple revisions while a tag represents a single revision.
The Subversion repository for your project hosted on this site supports branching and tagging your source files. Tagging and branching are easy and practical 'copy' operations for Subversion.
To create a branch or tag project files, type:
svn copy SRC DST -m "Type your message here"
Using command-line Subversion to access project source files的更多相关文章
- command line subversion for windows
安装 Slik SVN 之后,进入dos, 输入svn help,所有的命令和相关的信息都出来了 相关的svn命令:log.export等,可以搜索相应的文章: svn常用命令 svn log - ...
- Xcode 8.X Command Line Tools
Summary Step 1. Upgrade Your System to macOS Sierra Step 2. Open the Terminal Application Step 3. Is ...
- Xcode Command Line Tools for Mac OS X 10.9 Mavericks
by Daniel Kehoe Last updated 28 December 2013 How to install Apple Xcode Command Line Tools for Mac ...
- IAR Build from the command line 环境变量设置
http://supp.iar.com/Support/?Note=47884 Technical Note 47884 Build from the command line The alterna ...
- How to deploy a Delphi OSX project from the command line
Delphi has a well developed command line build process (via MSBuild) for Windows projects. After the ...
- Android Studio集成SVN报错:can't use subversion command line client : svn
Android Studio集成SVN插件,check out出代码后,每次开启都会在右上角出现如下错误: Can't use Subversion command line client: svn ...
- Android Studio集成SVN报错:can't use subversion command line client : svn
Android Studio集成SVN插件,check out出代码后.每次开启都会在右上角出现例如以下错误: Can't use Subversion command line client: sv ...
- Getting command line access to PHP and MySQL running MAMP on OSX
建立自己profile路径应该在/Users/yourname/,最后要运行. ./.profile使文件生效,和windows中给添加环境变量是一个道理,还可以看出linux和UNIX默认运行路径为 ...
- Can't use Subversion command line client: svn Probably the path to Subversion executable is wrong. Fix it.
1.最近使用SVN工具时,Checkout出项目到本地后后,然后将其导入到Intellij idea中开发,在提交svn代码的时候,出现这样的错误:Can't use Subversion comma ...
随机推荐
- HashMap 读后感
HashMap是一个哈希表,内部通过链地址法解决哈希冲突.内部用Entry数组保存数据,每个Entry是一个单向链表. HashMap不保证插入的顺序,线程不同步,允许null 下面是几个重要点: 保 ...
- java中的异常处理机制_函数覆盖时的异常特点
/*注意:异常声明在函数上 异常在子父类覆盖时的体现1.子类在覆盖父类时,如果父类的方法抛出异常,那么子类的覆盖方法,只能抛出父类的异常或者异常的子类2.如果父类方法抛出多个异常,那么子类在覆盖该方法 ...
- background-clip 背景图片做适当的裁剪
background-clip 用来将背景图片做适当的裁剪以适应实际需要. 语法: background-clip : border-box | padding-box | content-box | ...
- hibernate 知识梳理
一.hibernate背景介绍: 作者: Gavin King 分hibernate ORM(for relation db),OGM(for nosql db),hearch,validator,t ...
- CF 148A Insomnia cure
题目链接:传送门 题目大意:就是给四个数,和一个d,问1-d中有多少个数字不是那四个数的倍数; 这道题的d数据很小直接暴力可以过: 暴力代码:时间复杂度O(1): #include<stdio. ...
- phpcms v9 源码解析(4)content模块下的index.php文件的init()方法解析
在了解index.php中的init函数的时候,让我们先看看最开始的几行代码 1-5 第二行, defined('IN_PHPCMS') or exit('Nopermission resource ...
- Delphi XE5教程5:程序的结构和语法
内容源自Delphi XE5 UPDATE 2官方帮助<Delphi Reference>,本人水平有限,欢迎各位高人修正相关错误! 也欢迎各位加入到Delphi学习资料汉化中来,有兴趣者 ...
- 【转】常用插件和mvn test命令
自定义构建Maven项目,需要包括额外的插件或者配置已存在的插件参数. 1. maven-compiler-plugin 指定JDK版本和编码方式 compiler插件能解决2个问题: 第一: mav ...
- IOS开发之──应用之间调用(1)
iphone应用之间调用步骤: 1)在plist文件中,注册对外接口 在xcode group&files 里面,展开 resources选择<app>info.plist 鼠标右 ...
- 收起虚拟键盘的各种方法 -- IOS
使用虚拟键盘来输入资讯,是 iOS 的重要互动方式之一,虚拟键盘通常会自动出现在可以编辑的 UITextField 或是 UITextView 的编辑事件中,叫出键盘固然容易,但是要把它收起来,可就没 ...