subversion tortoisesvn tutorial

37
8/2/2019 Subversion TortoiseSVN Tutorial http://slidepdf.com/reader/full/subversion-tortoisesvn-tutorial 1/37 Page http://www.ictexpertise.com/ 1 Subversion TortoiseSVN tutorial ICT Expertise http://www.ictexpertise.com/ Copyright All rights reserved. This work is protected by copyright laws and international treaties. Not to be reproduced by any means without prior permission of the author that owns domain http://www.ictexpertise.com. Warning and Disclaimer Much care has been taken in writing this tutorial. However, the author can’t be held responsible for any errors that might exist in this tutorial. This tutorial is the result of author’s investigation on how to use branching and merging in Subversion. It’s the result of experimenting and author doesn’t claim it to be 100% accurate. Use it at your own risk. In case you think any information in this tutorial is incorrect, you’re kindly asked to report this by contacting the author at: http://www.ictexpertise.com.

Upload: richardz

Post on 05-Apr-2018

234 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Subversion TortoiseSVN Tutorial

8/2/2019 Subversion TortoiseSVN Tutorial

http://slidepdf.com/reader/full/subversion-tortoisesvn-tutorial 1/37

Pagehttp://www.ictexpertise.com/  

1

Subversion TortoiseSVN tutorial 

ICT Expertise

http://www.ictexpertise.com/  

Copyright All rights reserved. This work is protected by copyright laws and international treaties. Not to bereproduced by any means without prior permission of the author that owns domainhttp://www.ictexpertise.com.

Warning and Disclaimer Much care has been taken in writing this tutorial. However, the author can’t be held responsiblefor any errors that might exist in this tutorial. This tutorial is the result of author’s investigation onhow to use branching and merging in Subversion. It’s the result of experimenting and authordoesn’t claim it to be 100% accurate. Use it at your own risk.

In case you think any information in this tutorial is incorrect, you’re kindly asked to report this bycontacting the author at: http://www.ictexpertise.com.

Page 2: Subversion TortoiseSVN Tutorial

8/2/2019 Subversion TortoiseSVN Tutorial

http://slidepdf.com/reader/full/subversion-tortoisesvn-tutorial 2/37

Pagehttp://www.ictexpertise.com/  

2

After I installed Subversion, I created my Subversion repository on my computer. I’ve done this bycreating a folder called SVNRepository in the root of my C: drive. Just right-click on this folder andchoose Create repository here. 

After you created your repository, new folders will be added below the SVNRepository. Youshould not manually change anything in this folder and subfolders, because Subversion managesthis for us.

Next, create the following directory structure somewhere on your hard-drive, e.g. underC:\Projects:

Note that the trunk folder is the main development line of our sourcecode that will be used fordeployment of our applications. Branches will be used for making additions to our applications,which at a later point in time will be merged back to the trunk. The tags folder will be used forstoring stable deployment versions. Please note that above folders will not be filled, but theyserve as an easy way to fill our repository with the right tree-structure. These directories are onlyused once in order to do an import into the repository. After that import the Import folder andsubfolders may be deleted in case you want to.

In the Trunk directory create a textfile Test.txt:

Page 3: Subversion TortoiseSVN Tutorial

8/2/2019 Subversion TortoiseSVN Tutorial

http://slidepdf.com/reader/full/subversion-tortoisesvn-tutorial 3/37

Pagehttp://www.ictexpertise.com/  

3

Right-click on the ‘Import’ folder and select TortoiseSVN – Import.

Then the following dialog is displayed. Change the URL of the repository in order that the importwill be done under the SVNTutorial tree, like shown below. Enter a message: Import for example.

When you press the Ok button, the following dialog is displayed. Take note of therevisionnumber, which is 25.

Page 4: Subversion TortoiseSVN Tutorial

8/2/2019 Subversion TortoiseSVN Tutorial

http://slidepdf.com/reader/full/subversion-tortoisesvn-tutorial 4/37

Pagehttp://www.ictexpertise.com/  

4

In order to prove that the new tree is imported, right-click on the Import folder and chooseTortoiseSVN – Repo-browser.

In case needed, change the URL to the SVNTutorial path, like shown below.

Then the following structure is displayed in the Repository Browser. So we see that things wentwell. Also note the revision, which is 25 in our case.

Page 5: Subversion TortoiseSVN Tutorial

8/2/2019 Subversion TortoiseSVN Tutorial

http://slidepdf.com/reader/full/subversion-tortoisesvn-tutorial 5/37

Pagehttp://www.ictexpertise.com/  

5

Just for now close the Repository Browser, just click Ok. Next go to your Working Copy folder onyour computer and right-click and choose SVN Checkout:

In the following dialog change the URL of the repository so it’s pointing to the Trunk folder and thecheckout directory is the Working Copy folder on your computer and press Ok.

Page 6: Subversion TortoiseSVN Tutorial

8/2/2019 Subversion TortoiseSVN Tutorial

http://slidepdf.com/reader/full/subversion-tortoisesvn-tutorial 6/37

Pagehttp://www.ictexpertise.com/  

6

Then the following dialog is displayed, indicating the Checkout was succesful. Note once againthe revisionnumber 25. Only the trunk of the repository has been checked out to our WorkingCopy directory, which is fine, since we’ll be working on the trunk for the moment.

Now, when you look at your the folder structure on your computer, you’ll see the followingstructure. The green icons indicate that the Working Copy folder is now under version control.

Page 7: Subversion TortoiseSVN Tutorial

8/2/2019 Subversion TortoiseSVN Tutorial

http://slidepdf.com/reader/full/subversion-tortoisesvn-tutorial 7/37

Pagehttp://www.ictexpertise.com/  

7

When you open the Trunk folder, you’ll see the Test.txt file with the contents that were createdbefore. Make some changes to it in this Working Copy folder and save the file.

Commit the changes by right clicking on the Working Copy folder and choose Commit.

The commit will be done to our trunk in the repository, like shown below (see the Commit to:path). So this is correct. Type a message and press the Ok button.

Page 8: Subversion TortoiseSVN Tutorial

8/2/2019 Subversion TortoiseSVN Tutorial

http://slidepdf.com/reader/full/subversion-tortoisesvn-tutorial 8/37

Pagehttp://www.ictexpertise.com/  

8

Note that the revision is now 26. It has been increased by one.

Make a tag (because e.g. version 1.0 is delivered for testing) by right-clicking on the WorkingCopy folder and select TortoiseSVN – Branch/tag.

Make sure the tag will be done to the Tags/1.0 path in our repository. Note the revision that is 26in the dialog, which is ok because that’s the revision we have been working on. Also enter amessage and click Ok.

Page 9: Subversion TortoiseSVN Tutorial

8/2/2019 Subversion TortoiseSVN Tutorial

http://slidepdf.com/reader/full/subversion-tortoisesvn-tutorial 9/37

Pagehttp://www.ictexpertise.com/  

9

After that, a dialog will be displayed that the tag has been created and the revision is number 27.The tag should never be changed. It’s supposed to be a frozen state of development at e.g. acertain productversion.

The notice below indicates that the working copy is st ill on the previous path. This means that theWorking Copy folder on our computer is still pointing to the Trunk path in the Subversionrepository. That’s allright for now.

Page 10: Subversion TortoiseSVN Tutorial

8/2/2019 Subversion TortoiseSVN Tutorial

http://slidepdf.com/reader/full/subversion-tortoisesvn-tutorial 10/37

Pagehttp://www.ictexpertise.com/  

10

Now you want to do some work separate from the Trunk. Right-click on the Working Copy folderand choose again TortoiseSVN – Branch/Tag. Here we choose version 1.1 for our branch. Seebelow and check the checkbox 'Switch working copy to new branch/tag'. This means that fromnow on all our work in the Working Copy folder is done against the Branches/1.1 path in ourrepository. Any changes from now on in our Working Copy folder will be committed later on in therepository in the Branches/1.1 path. Press the Ok button.

Page 11: Subversion TortoiseSVN Tutorial

8/2/2019 Subversion TortoiseSVN Tutorial

http://slidepdf.com/reader/full/subversion-tortoisesvn-tutorial 11/37

Pagehttp://www.ictexpertise.com/  

11

A dialog will be displayed about the branch we did. Notice the new revision for the branch wemade: 28. Press the Ok button.

Page 12: Subversion TortoiseSVN Tutorial

8/2/2019 Subversion TortoiseSVN Tutorial

http://slidepdf.com/reader/full/subversion-tortoisesvn-tutorial 12/37

Pagehttp://www.ictexpertise.com/  

12

Now, do some work in our Working Copy folder with the Test.txt file and save the file.

While you’re busy with your work on the branch, suddenly you have to make a quick bugfix for anerror that is in your application that was tagged earlier with version 1.0. Therefore you want tomake the bugfix on the trunk.

Since our Working Copy folder is now pointing to the branch path in our repository, we should notmake the bugfix in our branch but instead we should fix that error in the trunk. This is because ourwork in the branch is not yet complete. So we have several options to choose. One is committingour source in our Working Copy and switch our Working Copy folder to the trunk in our repository.It is not always possible to commit your work in the branch, so another option is to create a newfolder under our SVNTutorial folder with the Windows Explorer.

Let’s call this new folder: Bugfix. It really doesn’t matter what name you use, because you can

always delete the folder later on when all changes are committed to the repository. You could forexample also call this folder Trunk.

So now our folder structure looks like this.

Note the red exclamation mark on the Working Copy folder. This is because we are still workingon our branches/1.1 and that work is not yet committed.

Page 13: Subversion TortoiseSVN Tutorial

8/2/2019 Subversion TortoiseSVN Tutorial

http://slidepdf.com/reader/full/subversion-tortoisesvn-tutorial 13/37

Pagehttp://www.ictexpertise.com/  

13

Now right-click on our new Bugfix folder and choose SVNCheckout

Since we want to work on our trunk to make the bugfix, we should choose that as the URL of therepository in the following dialog. Note the checkout directory is our new Bugfix folder.

Click Ok and the result of the checkout is displayed. We’re at revision 28, which is fine.

Page 14: Subversion TortoiseSVN Tutorial

8/2/2019 Subversion TortoiseSVN Tutorial

http://slidepdf.com/reader/full/subversion-tortoisesvn-tutorial 14/37

Pagehttp://www.ictexpertise.com/  

14

After you refresh your folder structure it should look like below.

When you open the Test.txt file in our Bugfix folder, you’ll see that the contents of it are still thecontents of the file as it should be under the trunk without our branch work. This is fine.

Now, change the content of this file so it will look like below. It’s just an example in which forconvenience I create an empty line. That’s where in our example later on the branch work will bemerged. In real life sourcecode it works similarly. Save the file.

Right-click on the Bugfix folder and choose commit.

In the next dialog you’ll see we’re committing against the trunk in our repository, which is what wewant. Enter some message and click Ok.

Page 15: Subversion TortoiseSVN Tutorial

8/2/2019 Subversion TortoiseSVN Tutorial

http://slidepdf.com/reader/full/subversion-tortoisesvn-tutorial 15/37

Pagehttp://www.ictexpertise.com/  

15

The commit has been finished and the following is displayed. We’re now at revision 29.

Our folder structure now looks like this. The green indicator shows that all work on our Bugfixfolder is in the repository.

Page 16: Subversion TortoiseSVN Tutorial

8/2/2019 Subversion TortoiseSVN Tutorial

http://slidepdf.com/reader/full/subversion-tortoisesvn-tutorial 16/37

Pagehttp://www.ictexpertise.com/  

16

Now we want to freeze the current situation in our trunk in a tag with version 1.0.1, so later onwhen a customer with application version 1.0.1 complains about this version of the application,we can investigate in this specific tag what causes the problem. Right-click once again on theBugfix folder and choose Branch/tag…, since we want to make a tag of our trunk in which a bughas been fixed.

Enter in the following dialog the correct path to our new tag 1.0.1, enter a message and click Ok.

Page 17: Subversion TortoiseSVN Tutorial

8/2/2019 Subversion TortoiseSVN Tutorial

http://slidepdf.com/reader/full/subversion-tortoisesvn-tutorial 17/37

Pagehttp://www.ictexpertise.com/  

17

The tag has been made. Take note of the revision number, which is 30. Click Ok.

Page 18: Subversion TortoiseSVN Tutorial

8/2/2019 Subversion TortoiseSVN Tutorial

http://slidepdf.com/reader/full/subversion-tortoisesvn-tutorial 18/37

Pagehttp://www.ictexpertise.com/  

18

Now comes a time that we want to merge the changes in the branch with the changes in thetrunk. Because in our example there are changes in the trunk, these changes must first bemerged into our branch (see step 1 below) and after that we merge the changes of the branchback to the trunk (see step 2 below).

In case there are no changes in the trunk that are not already in our branch, we can merge thechanges of our branch directly to the trunk (see step 2 below).

This sounds complicated, but it’s not.

Step 1 Merge the changes of the trunk (the bugfix) into our branch (the working copy)

Make sure the Working Copy folder is pointing to the branch in the repository. This is the case atthis moment when you followed this tutorial. In case your Working Copy folder is not pointing tothe branch, you should first switch your Working Copy to the branch. Switching your WorkingCopy folder will be explained later on, but this is not necessary at the moment.

Because we still have work in our Working Copy folder that’s not in our repository, we should firstcommit the changes in our Working Copy. Right-click on this folder and choose Commit.

Verify that we’re committing to the branch. This is indeed the case. Type a message and click Ok.

Page 19: Subversion TortoiseSVN Tutorial

8/2/2019 Subversion TortoiseSVN Tutorial

http://slidepdf.com/reader/full/subversion-tortoisesvn-tutorial 19/37

Pagehttp://www.ictexpertise.com/  

19

The commit has finished, the following dialog is displayed. Note the revision: 31. Click Ok.

The folders in your Windows Explorer now look like below (maybe you have to refesh yourfolderlist first).

Page 20: Subversion TortoiseSVN Tutorial

8/2/2019 Subversion TortoiseSVN Tutorial

http://slidepdf.com/reader/full/subversion-tortoisesvn-tutorial 20/37

Pagehttp://www.ictexpertise.com/  

20

Now we can do a Merge on the Working Copy folder. Right-click the Working Copy folder andchoose Merge…

In the newest TortoiseSVN, the Merge wizard is displayed. Choose ‘Merge two different trees’.

Page 21: Subversion TortoiseSVN Tutorial

8/2/2019 Subversion TortoiseSVN Tutorial

http://slidepdf.com/reader/full/subversion-tortoisesvn-tutorial 21/37

Pagehttp://www.ictexpertise.com/  

21

In the next dialog the fill in the From-textbox the URL to the trunk. It isn’t the URL to the branchbecause the branch doesn't have the changes that want from the trunk. At the moment we wantto try to update our branch with changes in the trunk.

We want to perform a diff between the last time the branch was synchronized with the trunk andthe head version of the trunk with the latest changes. Therefore the URL in the From-textbox ispointing to the trunk, the correct revision number is filled in and the To-textbox must also point tothe trunk while the HEAD Revision is choosen.

By the way, in older versions of TortoiseSVN just leave the checkbox ‘Use “From:” URL (…)checked. See below:

Page 22: Subversion TortoiseSVN Tutorial

8/2/2019 Subversion TortoiseSVN Tutorial

http://slidepdf.com/reader/full/subversion-tortoisesvn-tutorial 22/37

Pagehttp://www.ictexpertise.com/  

22

In my case below revision 26 was the last time the base of my branch was synchronized with thetrunk. I want to get all changes that were made from the moment my last branch (revision 26) wassynchronized with the base of the trunk up ’To’ the current HEAD revision. The result of this

merge should be stored in my current Working Copy folder (which points to my branches/1.1 inthe repository).

In case you wondered why I use revision 26, just go to the previous pages of this tutorial to seewhere we created our branch 1.1 or you can also press the Show log button in above dialog.Then the following dialog will be displayed and we can see revision 26 is the one that has all thechanges before we created our branch. In our example we can also use revison 28 that was theresult of making the branch. It doesn’t matter, because the bugfix in the trunk was not revison 28

or earlier. Note that in below dialog you only see the revision numbers that were made on thetrunk because we filled in the path to the trunk in the ‘From’ textbox.

Page 23: Subversion TortoiseSVN Tutorial

8/2/2019 Subversion TortoiseSVN Tutorial

http://slidepdf.com/reader/full/subversion-tortoisesvn-tutorial 23/37

Pagehttp://www.ictexpertise.com/  

23

The next step in our merge wizard will display the following dialog. Just don’t change anythingand maybe do a test merge by clicking on this ‘Test merge’ button. In the older TortoiseSVN youhave the possibility to click on ‘Dry run’, ‘Diff’ or ‘Unified diff’ (see below buttons). The ‘Diff’ and‘Unified diff’ are not available in the newer version of the program.

Page 24: Subversion TortoiseSVN Tutorial

8/2/2019 Subversion TortoiseSVN Tutorial

http://slidepdf.com/reader/full/subversion-tortoisesvn-tutorial 24/37

Pagehttp://www.ictexpertise.com/  

24

When we do indeed a test merge, we’ll see that there are conflicts. This is indeed correct, wehave to solve some issues. Click the Ok button.

Page 25: Subversion TortoiseSVN Tutorial

8/2/2019 Subversion TortoiseSVN Tutorial

http://slidepdf.com/reader/full/subversion-tortoisesvn-tutorial 25/37

Pagehttp://www.ictexpertise.com/  

25

Next click the Merge button and we’ll see the following dialog. In the older version we see anotherdialog in which we can also see the conflicted files (Test.txt) and we should solve the conflicts. Dothis in the older version of TortoiseSVN by right-clicking on this file in the dialog.

In the newer version of TortoiseSVN just click the Edit conflict button.

TortoiseMerge will then be opened in which we resolve our conflicts. I assume how this works, just make sure that the line with ‘Bugfix done in the trunk’ is merged into our working copy.

Page 26: Subversion TortoiseSVN Tutorial

8/2/2019 Subversion TortoiseSVN Tutorial

http://slidepdf.com/reader/full/subversion-tortoisesvn-tutorial 26/37

Pagehttp://www.ictexpertise.com/  

26

I resolved the conflicts by using mine for the first two conflicts and theirs for the last conflict. Theconflicts are indicated by the red exclamation mark. Then the screen will look like this. Save thechanges and close the screen.

After that click on the ‘Resolved’ button.

Then we’ll see that our merge was finished. Note that r27 through r31 were merged and click Ok.

Page 27: Subversion TortoiseSVN Tutorial

8/2/2019 Subversion TortoiseSVN Tutorial

http://slidepdf.com/reader/full/subversion-tortoisesvn-tutorial 27/37

Pagehttp://www.ictexpertise.com/  

27

Once the merge happens, your branch should now be synchronized with the trunk. When we lookin our Working Copy folder and open the Test.txt file we’ll see that the merge was done properly.

You’ll notice that the Working Copy folder now again has a red exclamation mark. This meansthat there are changes in our Working Copy folder compared to the branches/1.1 in ourrepository.

Step 2 Merge the changes of the branch (our work for our customer) into our trunk

Now you have a branch feature that you'd like to merge back into the trunk.

Since at this point, there are no more changes to the trunk in our example in case you followedthe tutorial, you can simply follow the steps below (Step 2) to merge your branch to the trunk.

However, if there have still been other changes to the trunk while you've been working on yourbranch, then you should:

1. First, merge trunk to branch as described in Step 1 to update your branch with the latest trunkchanges.2. Then merge your new features from branch to trunk, that is done here in Step 2.

Page 28: Subversion TortoiseSVN Tutorial

8/2/2019 Subversion TortoiseSVN Tutorial

http://slidepdf.com/reader/full/subversion-tortoisesvn-tutorial 28/37

Pagehttp://www.ictexpertise.com/  

28

As this is not the case in our example, we continue. First update your Working Copy folder. Dothis by right-clicking this folder and choose SVN Update. Note that sometimes an update is notalways necessary. This is done just to make sure the commit that follows later will succeed

without asking for an update first.

After that the following dialog is displayed. In case there was a conflict during the update wewould have been prompted in order to resolve those conflicts.

When we open our Test.txt file in the Working Copy folder, the contents are still the same. Thebugfix change is still there.

Then you can commit the changes in the Working Copy folder. Right-click that Working Copyfolder and choose Commit.

Page 29: Subversion TortoiseSVN Tutorial

8/2/2019 Subversion TortoiseSVN Tutorial

http://slidepdf.com/reader/full/subversion-tortoisesvn-tutorial 29/37

Pagehttp://www.ictexpertise.com/  

29

Note that the changes are about to be committed to our branches/1.1 in the repository. Enter amessage and click Ok.

The commit was succesful as shown below. Note the new revision number: 32. Click Ok.

Page 30: Subversion TortoiseSVN Tutorial

8/2/2019 Subversion TortoiseSVN Tutorial

http://slidepdf.com/reader/full/subversion-tortoisesvn-tutorial 30/37

Pagehttp://www.ictexpertise.com/  

30

Next, switch your Working Copy folder to the trunk. Do this by right-clicking the Working Copyfolder and choose Switch…

Make sure the path points to the trunk in our repository and click Ok.

After that you’ll see the switch was succesful and the revision is 32.

Page 31: Subversion TortoiseSVN Tutorial

8/2/2019 Subversion TortoiseSVN Tutorial

http://slidepdf.com/reader/full/subversion-tortoisesvn-tutorial 31/37

Pagehttp://www.ictexpertise.com/  

31

When you now open the test.txt file, you'll see that your changes that you did in the branch aremissing. This is perfectly fine, because now we're back to the situation of the trunk. The changeswe made in the branch are save in the repository.

Now we are going to merge. Right click the Working Copy folder and choose TortoiseSVN – Merge.

In the newer TortoiseSVN the Merge wizard will be displayed, however in the old TortoiseSVNthings are almost identical, you just don’t see the wizard.

Page 32: Subversion TortoiseSVN Tutorial

8/2/2019 Subversion TortoiseSVN Tutorial

http://slidepdf.com/reader/full/subversion-tortoisesvn-tutorial 32/37

Pagehttp://www.ictexpertise.com/  

32

In the merge window, we need to make sure we are going from the trunk to our branch. Thereasoning behind this is that we are doing a diff between the trunk and the branch. Or, startingfrom the trunk's current state to our branch's state. The trunk is the starting point for the branchchanges.

In the dialog you’ll see that the results of the merge are stored in our Working Copy folder. Leavethe revisons both on HEAD Revision. Click Next.

Page 33: Subversion TortoiseSVN Tutorial

8/2/2019 Subversion TortoiseSVN Tutorial

http://slidepdf.com/reader/full/subversion-tortoisesvn-tutorial 33/37

Pagehttp://www.ictexpertise.com/  

33

In the following dialog of the wizard you can do a Test merge to see how the merge will be done.Please note that in the older TortoiseSVN version this dialog is not available, like describedearlier on in this tutorial.

Page 34: Subversion TortoiseSVN Tutorial

8/2/2019 Subversion TortoiseSVN Tutorial

http://slidepdf.com/reader/full/subversion-tortoisesvn-tutorial 34/37

Pagehttp://www.ictexpertise.com/  

34

When we do this test merge, you’ll see something like the following dialog. Click Ok.

Because there were no problems we click the Merge button. After the merge the following dialogis displayed. Click Ok.

Page 35: Subversion TortoiseSVN Tutorial

8/2/2019 Subversion TortoiseSVN Tutorial

http://slidepdf.com/reader/full/subversion-tortoisesvn-tutorial 35/37

Pagehttp://www.ictexpertise.com/  

35

When you open the Test.txt file you'll see that our branch changes are now included.

Next you can commit the changes to the trunk in the repository by right clicking the Working Copyfolder and choose Commit. Please note in some cases you may need to update your WorkingCopy folder first. Subversion indicates that in case you’ll do a commit while there are still changesin the repository that must be updated first. In our example this is not the case.

Notice that now we're committing to the Trunk URL in our repository, which is fine (since weswitched our working copy back to trunk).

Page 36: Subversion TortoiseSVN Tutorial

8/2/2019 Subversion TortoiseSVN Tutorial

http://slidepdf.com/reader/full/subversion-tortoisesvn-tutorial 36/37

Pagehttp://www.ictexpertise.com/  

36

And again the revision number is increased by one and we’re done.

Now that we’re done and all our work is in the repository, it’s no problem to delete the Bugfixfolder (and eventually the Working Copy folder) in Windows Explorer, because we can allwaysmake a fresh SVN Checkout on a certain folder on our computer.

Page 37: Subversion TortoiseSVN Tutorial

8/2/2019 Subversion TortoiseSVN Tutorial

http://slidepdf.com/reader/full/subversion-tortoisesvn-tutorial 37/37

Page 37

I hope you learned something from this tutorial, I certainly did when I made it. Please contact mein case there are any inconsistencies.