The use and functionality of the SVN command

Source: Internet
Author: User
Tags commit create directory diff svn svn client svn update versions tortoisesvn
Use of Commands

1. Check out svn CO/HTTP path (full path of directory or file) [local directory full path]

--username User name--password password SVN co svn://path (full path to directory or file) [local directory full path]--username user name--password password
SVN checkout HTTP//path (full path to directory or file) [local directory full path]--username user name
SVN checkout svn://Path (full path to directory or file) [local directory full path]--username user name
Note: If you do not transfer the password with the--password parameter, you will be prompted to enter the password, it is recommended not to use the Clear text--password option.
Among them username and password before is two short-term, not one.
Does not specify a local directory full path, it is checked out to the current directory.
Example:
SVN cosvn://localhost/test Tool/home/testtools--username WZHNSC
SVN Co http://localhost/test/testapp--username WZHNSC
SVN checkout svn://localhost/test tool/home/testtools--username WZHNSC
SVN checkouthttp://localhost/test/testapp--username WZHNSC

2,Export (Export a clean directory tree without the. SVN folder)
SVN export [-R version number]/HTTP path (full path to directory or file) [local directory full path]--username user name
SVN export [-R version number] svn://path (full path to directory or file) [local directory full path]--username user name
SVN export locally checked out (i.e. with. SVN folder) directory full path to export local directory full path
Note: The first way to export a clean working directory tree from the repository is to specify the URL,
If a revision number is specified, the corresponding version is exported.
If no revision is specified, the latest export is exported to the specified location.
If the local directory full path is omitted, the last part of the URL is the name of the local directory.
The second form is to specify the local checked-out directory full path to the local directory full path to be exported, and all local modifications will be preserved.
However, files that are not under version control (that is, new files that are not submitted because the. SVN folder does not have information records associated with it) are not copied.
Example:
SVN export
svn://localhost/Test Tool/home/testtools--USERNAMEWZHNSC
SVN export
Svn://localhost/test/testapp--usernamewzhnsc
SVN export
/home/testapp/home/testtools

3. Add new files
SVN Add file name
Note: Tell the SVN server to add files, but also use SVN commint-m real upload up.
Example:
SVN add test.php <-added test.php
SVN commit-m "add my Test with test.php" test.php
SVN add *.php <-Adding all php files in the current directory
SVN commit-m "add my test with all PHP files" *.php

4. Submit
SVN commit-m "Submit Memo Message Text" [-n] [--no-unlock] File name
SVN ci-m "Submit Memo Message Text" [-n] [--no-unlock] File name
Must be taken with the-m parameter, the argument can be empty, but must be written on-m
Example:
SVN commit-m "Submit all Files under version control in the current directory" *<-Note this * indicates all files
SVN commit-m "Submit my Test with test.php" test.php
SVN commit-m "Submit my Test with test.php"-N--no-unlock test.php<-keep the lock on with the –no-unlock switch
SVN ci-m "Submit all Files under version control in the current directory" *<-Note this * indicates all files
SVN ci-m "Submit my Test with test.php" test.php
SVN ci-m "Submit my Test with test.php"-N--no-unlock test.php<-keep the lock on with the –no-unlock switch

5. Update files
SVN update
SVN update-r fix version file name
SVN update file name
Example:
There is no directory behind SVN update <-, and all files under the current directory and subdirectories are updated to the latest version by default
SVN update-r 200test.cpp <-Restore the files in the repository Test.cpp to the revised version (revision) 200
Svnupdate test.php<-Update is synchronized with the repository.
Prompt for expiration conflict when submitting, need update to modify file first,
Then remove the SVN resolved and commit the commit again.

6. Delete Files
SVN delete svn://path (full path to directory or file)-M "Delete Note information text"
The following actions are recommended:
SVN Delete file name
SVN ci-m "Delete Note information text"
Example:
SVN deletesvn://localhost/testapp/test.php-m "Delete test file test.php"
The following actions are recommended:
SVN deletetest.php
SVN ci-m "Delete test file test.php"

7. Locking/Unlock
SVN lock-m "Lock Memo Message text" [--force] File name
SVN unlock file name
Example:
SVN lock-m "lock letter Test with test.php file" test.php
SVN unlock test.php

8. Compare differences
SVN diff file name
SVN diff-r fix version number m: Fixed version number n file name
Example:
SVN diff test.php<-Comparing modified files to the underlying version
SVN diff-r 200:201 test.php<-difference between fixed version number 200 and revision number 201

9. View file or directory status
SVN St directory Path/Name
SVN status directory path/name <-directory in the state of files and subdirectories, normal status does not appear
"?: not in SVN control; M: Content has been modified; C: conflict;
A: To be added to the repository; K: Locked
Svn-v directory Path/Name
SVN status-v directory Path/name <-display file and subdirectory status
"The first column remains the same, the second column shows the work version number,
The third and fourth columns show the last modified version number and the modified person "
Note: The SVN status, SVN diff, and SVN revert three commands can be executed without a network,
The reason is that SVN retains the original copy of the local version in the Local. SVN.

10. View Logs
SVN log file name
Example:
SVN log test.php<-shows all the changes to this file, and its version number.

11. View File Details
SVN info file name
Example:
SVN info test.php

12. SVN Help
SVN help <-all features options
Description of the specific features of the SVN help CI <-

13. View the list of files and directories under the repository
SVN list svn://path (full path to directory or file)
SVN ls svn://path (full path to directory or file)
Example:
SVN list Svn://localhost/test
SVN ls svn://localhost/test<-displays all files and directories belonging to the repository in the Svn://localhost/test directory

14. Create a new directory under version control
SVN mkdir directory Name
SVN mkdir-m "New directory Memo text"/HTTP/Directory full path
Example:
SVN mkdir Newdir
SVN mkdir-m "Making a new dir." Svn://localhost/test/newdir
Note: After adding subdirectories, be sure to go back to the root directory update, or the file will be submitted in this directory would prompt "commit failed"
SVN update
Note: If you create a new folder Newsubdir manually in the checkout directory,
After using the SVN mkdirnewsubdir command, SVN will prompt:
SVN: Try using "svn add" or "svn add--non-recursive" instead.
SVN: Unable to create directory "Hello": File already exists
At this point, use the following command to resolve:
SVN add--non-recursivenewsubdir
When you enter this Newsubdir folder, you can see all the directories and files below it with ls-a:. SVN directory
Then use the SVN mkdir-m "Add Hello Function module file" Svn://localhost/test/newdir/newsubdir command,
SVN tip:
Svn:file already Exists:filesystem '/data/svnroot/test/db ', transaction ' 4541-1 ',
Path '/newdir/newsubdir '

15. Restore Local Modifications
svn revert [--recursive] file name
Note: The notebook command will not access the network and will release the conflicting condition. However, it does not restore the deleted directory.
Example:
svn revert foo.c <-discard changes to a file
svn revert--recursive. <-restore a whole directory of files,. For the current directory

16. Update the work copy to another URL
SVN switch/HTTP/directory full path local directory full path
Example:
SVN switch http://localhost/test/456. <-(formerly 123 Branch) is currently located in the directory branch to localhost/test/456

17. Conflict resolution
SVN resolved [local directory full path]
Example:
$ SVN update
C foo.c
Updated to revision 31.
If you get a conflict during the update, your working copy will generate three new files:
$ ls
Foo.c
Foo.c.mine
Foo.c.r30
Foo.c.r31
When you have resolved the FOO.C conflict and are ready to submit, run SVN resolved and let your working copy know that you have done everything.
You can simply delete the conflicting files and submit them, but svnresolved also fixes some record data in the work Copy management area, in addition to deleting the conflicting files, so we recommend you use this command.

18, not checkout and view the content of the output specific file or URL
SVN CAT/HTTP/File full path
Example:
SVN cathttp://localhost/test/readme.txt

19. Create a new branch copy

SVN copy branchabranchb-m "make B branch"//Copy a new branch from Brancha BRANCHB

20. Merge content to branch merge

SVN merge Branchabranchb//merge changes to Brancha to branch BRANCHB

SVN features in a detailed

TortoiseSVN is one of the most excellent SVN client tools under Windows. By using it, we can visualize the management of our repository. However, because it is only a client, it cannot manage permissions on the repository.

TORTOISESVN is not a standalone window program, but is integrated in the Windows right-click menu, which is convenient to use.


TortoiseSVN what each menu item means


01. SVN Checkout (svn out)
Click SVN Checkout, pop up the checkout prompt, enter the server warehouse address in the URL of repository input box, enter the path of the local working copy in the Checkout directory input box, click OK to check out the configuration library on the server.

02. SVN Update (SVN updates)
If the configuration library has a working copy locally, the latest version is just the SVN update, click on SVN update, the system pops up the update prompt box, click OK, then the latest version of the server is updated

03, Import (Imports)
Select the directory to submit to the server, right-select the TORTOISESVN----import, the system pops up the import prompt box, enter the server warehouse address in the URL of repository input box, enter the import log information in the Import message input box, click OK , the file is imported into the server warehouse.

04. Add (Add)
If there are multiple files and folders to submit to the server, we can first add these to submit the file to the submission list, to perform the commit operation, one time to submit all the files, such as the diagram, you can select the file to be submitted, and then click Execute Commit (SVN commit), All files can be submitted to the server at once

05. Resolving Conflicts (conflict resolution)
Sometimes you might have a conflict when you update files from the archive. A conflict arises when two people are modifying a part of a file. Conflict resolution can only be done by people rather than by machines. When a conflict occurs, you should open the conflicting file and find the line starting with <<<<<<<. The conflicting parts are marked:
<<<<<<< filename
Your changes
=======
Code merged from repository
>>>>>>> Revision
Subversion generates three additional files for each conflicting file:
Filename.ext.mine
The local file before the update.
Filename.ext.rOLDREV
You make changes to the base version.
Filename.ext.rNEWREV
The latest version from the archive when updating.
Use the Edit Conflict Editor Conflict command on the shortcut menu to resolve the conflict. Then execute the resolved resolved command from the shortcut menu and send the changes to the archive. Note that resolving a command does not resolve the conflict, but simply deletes the filename.ext.mineandfilename.ext.r* file and allows you to send it.

06. Check for modifications (checking for updates)
Click Check for modifications, system list so the status of the files and folders to be updated.


07. Revision Graph (Version branch chart)
View the branch of the file, the version structure, you can click Revision Graph, the system graphically displays the version of the branch.

08. Rename (renamed)
SVN support file Renaming, click Rename, pop-up file name input box, enter a new file name, click OK, and then submit the changes, you can complete the file renaming

09. Delete (Remove)
SVN support file deletion, and easy to operate, convenient, select the file to delete, click Delete, and then submit the delete operation to the server

10, Moving (mobile)
Select the files and folders to be moved, press and hold right-drag the Right-drag file (clip) to a new place in the tracking copy, release the left button, and select Move files in the pop-up menu.

11, Revert (Restore)
Restore operation, such as the file has been deleted, now restore it back, click Delete, then click Submit, will appear as on the Prompt box, click Delete, then click Revert, that has been revoked delete operation, if this time click Submit, then the system pop-up Prompt box: No file was modified or added, can not be submitted

12, Branch/tag (branch/Mark)
When you need to create a branch, click Branch/tag, in the pop-up prompt box, enter the branch file name, enter the log information, click OK, the branch is created successfully, and then you can view the version branch of the file

13. Switch (toggle)
After the file has been created, you can choose to work in the trunk or branch, and you can switch by switch.

14. Merge (merger)
The trunk and branch versions are merged, the path of the input files in the source and destination, the version number, click OK. The system merges the files and, if there is a conflict, refer to conflict resolution.

15. Export (exporting)
Export the entire work copy to a local directory, the exported file will not have the SVN file flag, the files and folders do not have a green "√" sign.

16. Relocate (reposition)
When the file vault directory on the server has changed, we can reposition the working copy and enter the new address in the To URL input box

17. Add to Ignore list (added to ignore list)
Most projects will have some files (clips) that do not require versioning, such as compile-generated *.obj, *.LST, etc. Each time you send, tortoisesvn tips those files do not need to control, very annoying. These files can be added to the Ignore list at this time.

18, SVN Other related functions
Client modifies user password:
Open the browser, enter HTTP://192.168.1.250/CGI-BIN/CHANGEPASSWD in the Address bar, start the client to modify the user password interface, enter the correct user name, old password, new password (note the password should not be less than 6 digits, try to use a secure password ), click Edit.

19. SVN Commit (version submission)
Commit the changes you made to your work copy to the repository so that others can see your changes when they get the latest version (update).

20, show log (display logs)
Displays the history of all modifications to the current file (clip). SVN supports file and folder-independent version traceability.

21, Repo-browser (view current repository)
View the current repository, this is the TortoiseSVN view repository of the portal, through this menu item, we can go to the configuration library of the resource manager, and then we can manage the Configuration Library folder, the equivalent of we open My computer for file management.

22. Revision Graph (version graphics)
View the Revision history icon for the current project or file. If the project is large, it will usually build multiple branches, and multiple milestones (stable release), through which we can see the full picture of the project.

23. Resolved (conflict resolution)
If there is a conflict between the current working copy and the repository and cannot be merged automatically, then when you commit the change, TORTOISESVN will prompt you for a conflict, and you can resolve the conflict by this menu item. There are two kinds of conflict resolution, one is to keep a copy, such as using a configuration library to overwrite the current working copy, or vice versa. There is also a manual resolution of the conflict, for a text file, you can use TortoiseSVN's own tool, it will list where there are conflicts, and then you can discuss with the submitter how to resolve the conflict. It also has a good support for word.

24. Update to Revision (updated to version)
Get a version of a history from the repository. This feature is primarily useful for viewing historical versions, rather than rolling back versions. Note: No action is recommended for this file after it has been obtained. If you make a change, then when you submit SVN will prompt you, the current version is invalid (that is, not the latest version), unable to submit, you need to update first. So the changes you've made are in vain.

25, Revert (rollback)
If you've made some changes to your work copy, but you don't want it, you can use this option to undo the changes you made.

26, Cleanup (Clear State)
If you have any problems with your current working copy, you can use this option to correct it. For example, some files are originally version-controlled, but you did not delete them directly by TORTOISESVN, But TortoiseSVN still retains the original information (there is a. svn hidden folder under each folder that holds the version information for all folders under the current folder) so this creates some conflicts. You can use the cleanup to clean up a bit.

27, Getlock/releaselock (Locking/unlock)
If you don't want someone else to change a file, you can lock the file so that only you have the right to modify the file. Unless you release the lock, others cannot commit any changes to the configuration library

28. Branch/tag (branch/label)
Branch is the meaning of the branch. For example, when designing a thing, different people have different implementations, but no practice test, who do not want to directly cover the other people's design, so can lead to different branches. You can merge these branches in the future if you want.
Tag is the meaning of marking. Usually when the project is developed to a certain extent, it can be run stably, it can be labeled as a stable version. In the future can be convenient to find a specific version (of course we can also use the version number to find, but the number is not convenient)
SVN for branches and tags are similar to the way Linux hard links (the same file can exist in two places, delete one does not affect the other, the modification will affect the other), to manage the file, rather than simply copy a copy of the file, so there will be no wasted storage space problems exist.

29. Export (exporting)
This feature is handy for our deployment. When we need to publish a stable version, we can use this feature to export the entire project to a folder, and the new folder will not contain any version information.

30. Relocate (repository transfer)
This feature is required when our repository is transferred. For example, my original repository was built on a USB flash drive and is now transferred to the development server (copying the entire Configuration Library folder), using HTTPS instead of the file system access. Therefore, the target repository of the original working copy needs to be relocated to the development server.

31. Create patch (creates patches)
Create patches. If the administrator does not want anyone to submit the changes casually, but will have to be audited to make changes, then others can create a patch, the modification information (patch file) to the administrator, the administrator after the audit, you can use the Apply patch to submit the changes.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.