Learn to Make Revisions in Code Repository:
Our previous tutorial in this series explained, how to Set up a free server repository of your own and set up a Tortoise SVN UI client.
In this tutorial, we will be learning about how to use the Tortoise SVN client to check out and check in the code from/to the repository. Read through this Entire Subversion Training Tutorials for a complete understanding of the concept.
Table of Contents:
Revisions in Code Repository by Check-in/Checkout using TortoiseSVN
Let us open the Eclipse IDE.
** If you do not have Eclipse set up in your machine then you can refer here and that will help you in setting up eclipse.
** You can install java (Java Runtime Environment or JRE) from here.
** Once you install JRE, then you can install eclipse.
Browse and select a place where you would like to create your workspace.
Click Launch.
Click Workbench. Now inside this workspace, we will create a very simple java project (File => New =>Java Project).
Mention the project name as seen below.
Click Finish. Select the src folder as shown below.
After selecting the src folder, right-click and further click on ‘New’ => Class.
Mention some class names (here ‘PracticeSVN’) and select the checkbox as ‘public static void main’.
Click Finish. Now in this class, let’s write a simple SOP (system.out.println) statement.
Suppose we want to put this project into the server which is the common centralized repository for all the team members. In order to do this, the team members must know how to check in the code inside the server and how to check out (extract) the code from the server onto their local machine.
Let us see how the check-in works. We will now check the project that we have created above to the repository. Select your project and right-click it.
Click Properties, and this will tell us the location of our project, select the location up to the ‘Workspaces’, right-click and then copy the location.
Just go to this location.
Right click on your Project => click ‘TortoiseSVN’ => click Import (this means check-in into the repository).
Mention the name of the repository URL.
Click OK. This will connect your local machine to the server (you must be connected to the internet).
You will get the authentication screen in which you have to enter the same login credentials that you had created while creating a repository.
Click OK, and you will start seeing the files getting transferred to the repository and the import will complete in 4 minutes.
Click Ok. Now refresh the repository page. As shown below the project comes inside the server. At the bottom, we can see that the repository revision is at 1.
Go inside the src folder, and you will find the PracticeSVN.java that we created.
Click PracticeSVN.java, and you will see the code that we had written.
Thus we have successfully checked our code into the server repository.
Now we would like to do the opposite or bring the code back from the repository to our local machine. In other words, we would like to check out the code from the repository. To do that, let us create a blank folder in our local machine and name it ‘CheckoutSVN’.
Now right-click on this folder => ‘TortoiseSVN’ => ‘Export’.
When you click ‘Export’ the below window comes up. The repository URL will be automatically populated. The export directory will show the location of the folder in your local machine where you would like to check out the code.
Click OK. The export starts and gets finished within 10 seconds (in this case).
Click OK
Go inside the folder ‘CheckoutSVN’, and you will see the contents of the repository. If you further go inside the src folder, you will see the java file that we had created. Thus our checkout is successful from the server repository to our local machine.
Conclusion
This tutorial explained the simple concept of SVN. We just have to install the Tortoise SVN client and check out/check in the code from/to the repository.
Thus in this tutorial, we have practically learned how to check out the code from the repository and how can we check in the updated code into the repository.
In the upcoming tutorial, we will learn how to delete the code content from the repository.