SVN usage and problem solving

checkout project files.

    Create a new or enter the directory (such as qianduan1), right click --> Svn Checkout -->

The URL I can get from the SVN server, I right-click under myRepositories to create a new file

 

The qianduan file is created, then right-click like me --> copy

That's it.

Paste the copied repository URL, as shown below:

After clicking the [ok] button, you can retrieve it, as follows:

As shown below:

 

Precautions:

   The .svn hidden directory records two key pieces of information: the baseline version of the working file and the last updated timestamp of a local copy. Do not manually modify or delete this .svn hidden directory and the files in it!!, otherwise it will lead to Your local working copy (static attempt) is destroyed and can no longer be manipulated.

  1) TortoiseSVN icon introduction

    

   A newly checked out working copy is reloaded with a green checkmark, indicating that Subversion is in a healthy state.

    

  After you start editing a file, the status has changed to Modified and the icon overload has changed to a red exclamation mark. This way, you can easily see which files have been modified since the last time you updated your working copy and need to be committed.

     If there is a conflict during the submission process, the icon will turn into a yellow exclamation mark.

    

The plus sign tells you that a file or directory is planned to be added to version control.

2) TortoiseSVN Client basic operations:

    1. SVN Checkout

     Right-click on the folder or directory -> select SVN checkout, as shown in the following figure

     

  After clicking, enter the directory address of the repository in the repository url box of the pop-up window, and then click OK, as shown below

 

After clicking the ok button again, as shown below:

Enter the user name and password in the pop-up dialog box. After the verification is successful, the project file starts to be downloaded from the remote server to the local working directory.

After clicking the ok button, the acquisition is complete, as shown in the following figure:

 2. Add

  Under the test project file, create a new b.txt file and submit it to the repository in the following two ways:

   1. First mention the change list, then commit to the configuration repository, select the new file, right-click the SVN menu and execute "Add" operation to submit to the "change list", then right-click the SVN menu and execute "SVN Commit" to submit to the repository middle.

   2. Instead of committing to the change list, directly commit to the configuration repository, select the file, right-click on the svn menu and execute the "SVN Commit" operation.

  3. Delete

     If the deleted file has not yet entered the repository, you can directly delete the file by using the delete operation of the operating system.

     If the deleted file is already in the repository, the method of deletion is as follows:

  1. Select the deleted file, right-click the svn menu to execute the "delete" operation, then select the parent directory of the deleted file, right-click the svn menu to execute "SVN Commit".

Use the delete operation of the operating system to delete the file, then select the parent directory of the deleted file, right-click the svn menu to execute "SVN Commit", and select the deleted file in the change list. As shown below:

   

 4. Rename

    Modify the file name, select the file or folder that needs to be renamed, then right-click "TortoiseSVNàRename", enter the new name in the pop-up dialog box, click the "ok" button, and pass the modified file or folder through "SVN à Rename" Commit" to the SVN server.

 5. SVN Revert

    Right-click the file or folder you want to revert, select "Update to reversion..." in the TortoiseSVN pop-up menu, and a window will pop up, as follows:

  

For example, if we want to roll back to the 10th version, we only need to fill in the corresponding version number in Revision, and then click ok.

 6. Check for modifications

     This function can show which changes you have made that have not been submitted yet. This function can not only see the changes to the file, but also all changes, including adding files or directories, deleting files or directories, moving files or Directory, etc. If you click Check Repository, then you can also see the changes in the repository, and you have not updated the changes of which files have been submitted by others, as follows:

  

 7.  SVN更新(SVN Update)

    Update the local code to be consistent with the latest version on the SVN server, just right-click on the folder that needs to be updated or right-click on the blank space under the file, and select "SVN Update" (to get the content of the specified version, right-click to execute the SVN menu "Update to reversion"), it will be fine.

 7.1 How to resolve conflicting files

     For each conflicting file Subversion places three files in your directory: the following:

   

     Why does conflicting code occur? The reason is very simple because different people have modified the same place of the same file at the same time. At this time, he submitted it, but I didn't submit it, so I couldn't submit it. At this time, we have to update first, and then submit it. , then if there is a conflict, the above 3 files will be generated. 

The solution is as follows:

      First we can look at the 1.txt code as follows:

        <<<<<<< .mine

        aaaasdf11222333 dderderder

        =======

       b>>>>>>> .r5

      Then I remove the redundant code, 1.txt becomes like this

      aaaasdf11222333 dderderder

      Make a submission, but still can't submit, as shown below:

    

  Why? Because the conflict will generate the above three files, if the above three files exist, it must not be submitted. The codes and explanations of these three files are as follows:

  1. 1.txt.mine is its own file before the conflict. You can see the following:

      aaaasdf11222333 dderderder

      2. 1.txt.r4 is the local version file before the conflict

     The content is as follows: aaaasdf11222333

      3. 1.txt.r5 is the version submitted by others before you

      The contents are as follows: b

Among them, the code between <<<<<<<<.mine.....======== is your own, and ======......>>>> >>>.r5 is the part of the code that others conflict with you

It is not difficult to understand why there is such a strange thing as a conflict, because the same piece of code you modify will of course conflict.

The solution is as follows:

  1. Suppose that the conflicting content in my current 1.txt is as follows:

      <<<<<<< .mine

       6666666666666600000

       =======

      66666666666aaaaaaaaaa666

      >>>>>>> .r16
    前面说过  <<<<<<< .mine …… =======

    The code between ... is the code I modified before there was no conflict,

    ======= ...……>>>>>>>> .r16 The code in the middle... is the part of the conflicting code between others and me. From the above code, we can see that aaaaaaaaa was added by my colleague, 00000 I added it later.

    1. Use the revert (rollback) operation, which means that the user abandons his updated code and then submits it directly. At this time, your code will be the latest code on the server, that is, the new code submitted by user A, and your code will not be changed. commit as follows:

      After clicking the ok button, you can see that the other three files are automatically deleted, and the 1.txt code becomes the following code:

      66666666666aaaaaaaaaa666

      That is, the code submitted by user a. The code I updated myself needs to be copied into it myself to submit the commit.

    2. Suppose I now have a conflicting code in 3.txt as follows:

      <<<<<<< .mine

      333333338888888888888=======

      3333cccccccccc3333>>>>>>> .r16

      From the first point, we know that the content of 333333338888888888888 is the content after I modified it without conflict. The code 3333cccccccccc3333 is the code submitted by user A. From the above, we know that the new content of user A is ccccccc, and the content I added is 8888888.

      Then the second solution is as follows:

                    Select File -> Right-click Editconficts: This method requires both parties to the conflict to negotiate and unify the code changes before submitting. Not only is the conflict resolved but the code is guaranteed to be correct as only one side's code is committed.

     

   As shown in the figure above, the red part is the conflicting code: theirs represents the latest code on the current server, Mine represents the modified code, and Merged represents the merged code. Right-click on the red and select: use this text block to use this part of the code as the merged code

Next, let's talk about the situation where important code is covered due to conflicts. If you take the wrong measures when a conflict occurs, parts of the code may be lost, and it is easy to restore the previous code if you want to.

Select File -> Right-click and select show log, where you can see all the previously submitted versions, find the version you want to restore, right-click and select revert to this version to restore.

SVN Commit

    Svn submission is to submit the modifications made in the workspace, including modification of file content, addition, deletion, naming, and movement of files or directories. As shown below:

   

  8. Show log

       Through this function, you can find out who and when did those operations on those files in that directory, as shown below:

  

 9. Repo-browser

     This function is used to browse the database to be viewed, right-click under the local folder, select TortoiseSVNàRepo-browser, enter the database address in the pop-up dialog box, and then enter the user name and password, and you can view what you need to view. The contents of the repository, where you can also see who locked those files, as shown below:

   

Three: Create branch merge interoperability

   Why create branches and merge in projects?

      For example, all files of my current project are placed in the trunk. Due to the change of requirements, new requirements need to be added, but we have to continue to develop on the trunk. Here we can create a new branch to add new requirements. For the part of the requirements, continue to develop on the trunk, and merge it into the trunk when there is no problem with the code on the branch.

The biggest purpose of creating a branch is to do parallel development with the mainline without affecting the development of the mainline.

   How to do it?

      If I create a new folder test locally, there are 2 folders trunk (to store the code on the trunk) and branch (to store the code on the branch), as shown below:

  

One: Extract the code on the trunk first.

   Click trunk --> Right mouse button --> Click SVN Checkout --> A dialog box will pop up, as shown below:

  

The above URL is obtained from the server VisualSVN Server as follows:

 

  Just right-click qianduan3 --> Copy URL to Clipboard.

  The qianduan3 project has the following files, as shown in the following figure:

Finally, after clicking the checkout button above, you can get the code from the remote server on the trunk, as shown below:

 

Two: create a new branch

  The steps to create a branch from trunk (on the trunk) are as follows:

  1. Right-click trunk --> branch/Tag as shown below:

  

  The dialog box that pops up is as follows:

  

  After clicking the ok button, you can add newBranch on the VisualSVN Serval server, which is copied from the file on the above server qianduan3, as shown below:

  

Now we can look at the local branch folder again. I now directly enter the branch file, right-click --> Chenckout, and extract all the files under newBranch, as shown below:

 

Click the ok button to extract the file, as shown in the following figure:

The branch is currently established on the server side of svn, and it is not updated locally. Right-click on the local branch folder --> update, and then update to the branch code, as shown below:

Four: Merge the branch to the trunk

   For example, I now add a 3.txt file to the branch branch, and then submit it, as shown below:

  

I now want to merge the code 3.txt on the branch to the trunk on the trunk. How do I merge it now? Proceed as follows:

  1. Go back to the trunk folder we just created, right-click the folder --> TortoiseSVN --> Merge as shown below:

  

In the pop-up window, as shown below:

 

Then click [Next], as shown in the following figure:

Then proceed to [Next], as shown in the following figure:

 

You can see that an additional 3.txt is added to the trunk trunk, which is merged from the branch.

Five: Merge trunk to branch.

 If there are some updates on the trunk, such as jar package updates, etc., then these should be updated to the branch, how to operate? For example, I now create a new 4.txt file on the trunk, such as the following:

 

The directory on my current branch is as follows:

Now I want to merge 4.txt on the trunk to the branch. How to do it?

The steps are as follows, which is still similar to the previous operation.

 1. We click branch on the branch --> right-click TortoiseSVN --> Merge as shown below:

 

After a new window pops up, as shown below:

Then click [Next], as shown in the following figure:

 

Continue to the next step, as shown below:

Finally, merge directly, you can see that the branch also has the 4.txt file on the trunk, that is to say, it is also possible to merge the trunk to the branch, as shown in the following figure:

 

 

Reprinted from http://www.cnblogs.com/armyfai/p/3985660.html

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325587182&siteId=291194637
Recommended