Some common commands for SVN under Linux

Source: Internet
Author: User
Tags svn svn client svn update

Recently in the Linux system to play some svn things, feel a mess of head, so I tidied up some beginners must understand the basic commands:

1. SVN--version: View the SVN client version under the Linux system. Client side version should be consistent with the server version, otherwise there will be some bugs, such as may appear can not be svn commit (really took a long time to find this problem, really is the experience,).

The way to view the version of SVN server on the client computer is to enter "http://www.SERVER_NETWORK_ADDRESS.com/SVN_REPOS_ADDRESS/" on the browser. This address can be found under the SVN Info command (Repository Root).

2. SVN co server_path: Send the file under the target server to check out (can be understood as download) out to your own computer.

For example, check out the following documents: A.txt, B.txt, C.txt, D.c,i.txt

3. How to upload a new file:

First step: Create a new, local file to upload in checkout directory touch E.txt

Step two: SVN add e.txt appears with the result "A e.txt". A stands for e.txt (add) to the repository (the personal understanding is to add the E.txt information to the Local. svn file, which is not yet inside the SVN server).

Step three: svn commit-m "annotation Information". This is the time to upload the local e.txt to SVN server. "-M" Annotation Information "" is required, not less, otherwise an error.

You can also svn commit e.txt-m "comment info", but this is just uploading the e.txt to SVN server. If the first step, we created two files E.txt and F.txt, the second step we add E.txt, f.txt, then svn commit e.txt-m "comment" Upload only e.txt, and svn commit-m "comment Information" upload all add Ed's file.

SVN commit abbreviated to SVN CI

4. After uploading the file, how to delete the file:

Fourth step: SVN delelte a.txt appears as the result "D a.txt". D represents a.txt being scheduled to be removed from the repository (Del). Then see the local directory, A.txt disappeared, was deleted by SVN.

Fifth step: SVN ci-m "annotation Information", the DEL information is passed to the server, the server performs the delete task.

Do two experiments:

A) Manually right-click Delete B.txt in the local directory and execute SVN ci, resulting in no response. Check out a copy of the entire directory (or svn up), found that B.txt re-appear, which means that can not be silly manual deletion of files Ah, invalid, must follow the rules of SVN (this is very important, because some of our assumptions will lead to some unpredictable results, experience)

b) When there is no network, SVN add and SVN del can operate, but SVN commit cannot operate. Note that add and Del two SVN actions operate locally, while commit is a networking behavior.

5. When we have modified a check out file, for example, in C.txt add a "Hello world!", how to update the SVN server inside the c.txt?

SVN ci c.txt-m "Modify the C.txt".

Summary, if check out of the file, direct SCN ci; how a file is not a check out file, then you need svn add and then in SVN ci.

6. SVN update-r version path/filename: Update to a version (-R means revert). Notice that every time we have svn ci, he will have a version number. When we debug the code file (D.C) countless times, we find that the first code is the most elegant, so we can restore the original settings by version number: SVN up-r 1232 (initial version number) D.C. But other a.txt,... The file is also the latest version, the entire folder is also the latest version, only D.C is the old version (a bit around, manual operation). So are we going to record every version number? No, SVN log will tell us the version number at different times, but write the comment information for each commit so that it can be distinguished.

7. SVN status path (status of files and subdirectories under directory, normal status not shown)

"?: Not in SVN control (you manually set up a file that hasn't been added to the repository after SVN add?"). will become a); M: content has been modified; C: conflict; A or D: scheduled to be added or deleted to the repository; K: Locked "

8. SVN Log path: Displays information for each modified version number and comment

9. SVN switch (SW) Branch: Converts the current branch to a different branch. Because many people use a set of SVN server, if everyone can change the code inside the SVN server arbitrarily, the entire SVN server code will be very confusing. So you need to assign each person a branch (or even a branch per question). If you look at the current branch, enter SVN info directly, it's clear. In general, our first check out branch is called ADB. Find some subdirectories under the ADB branch file we want to work with, and switch ADB branch to our SVN branch. Need practice.

Note: Every time svn SW, be sure to svn ci to SVN server, or the next time switch back, the modified file will not be svn ci into the server inside. (Workaround: If we have modified I.txt, before CI, we SW to another branch.) Then SW back, Touch i.txt; svn revert i.txt;svn add i.txt; SVN ci i.txt-m "Recover the I.txt")

SVN diff path: For example, after changing the a.txt, there is no CI, direct svn diff, you can see what changed before. If after CI, it can be compared in the following form: SVN diff-r m:n a.txt (difference between version m and version N). Be sure to execute the SVN diff command in the current working copy. Note ADB Branch and Working copy (branch) are the same revision. So we can get the difference between the ADB branch and working copy via SVN diff. The ADB revision is the first revision under the SVN log command, not the current revision (because the current ADB branch and Working copy (branch) are the same revision).

Confusing, right? We need spend time playing around with SVN to master it. Better luck!

Some common commands for SVN under Linux

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.