Easy-to-follow video tutorials help you learn software, creative, and business skills.Become a member

Branching and merging

From: Fundamentals of Software Version Control

Video: Branching and merging

The last major piece of functionality we need to explore is branching and merging. In SVN, it's done much like tagging. We create the branch from the common parent directory, the one containing the trunk, tags and branches by using svn copy. So let's go back up to the parent directory, make sure we're in the right place, there we can see branches, tags, and trunk, and then we'll execute the following command, svn copy trunk branches\b1, our branches are going to be called b1.

Branching and merging

The last major piece of functionality we need to explore is branching and merging. In SVN, it's done much like tagging. We create the branch from the common parent directory, the one containing the trunk, tags and branches by using svn copy. So let's go back up to the parent directory, make sure we're in the right place, there we can see branches, tags, and trunk, and then we'll execute the following command, svn copy trunk branches\b1, our branches are going to be called b1.

Once again, you can see this is pending, it hasn't actually been created yet. So we do a commit again and create branch b1. Scroll off to the top of the screen, once again log more. There we see it, created branch b1 that's revision 6. Now you notice that SVN doesn't make a distinction between your branches and the trunk in terms of its revision numbers.

All updates go to the same list of revisions, each with its own revision number. This is because the revision number represents revision of the entire repository, not just of a single file. So, to work with the branch we have to go into branches b1 and make an update. So in this branch we'll add a method called feature1, No more available space, Look to the cloud, Your hard drive is full. All right, and then we'll save this.

Now if we ask SVN for the status, you can see that we've modified file f1.c and the branches b1 directory. If we switch back to the trunk directory and ask SVN status, you can see it shows no changes, so it's keeping these independently. So now we'll switch back to the branch, and we commit.

And then I'll update, and there is a shortcut for SVN updates, just svn up. And there we can see Branch b1: Added feature 1. You might note that I put the words branch b1 in front of the commit message. That's because subversion doesn't track for you which branch changes are made in, so therefore a convention that's often used is include the branch name in the update message. So, let's quit this and talk about merging.

If you want to continue to work in a branch for an extended period or time, you want to do a forward integration from the trunk from time to time. That time varies based on how active the trunk changes are if somebody is actually working there. Usually, you do that weekly. You do that so that your branch doesn't get too far out of date with changes in other areas of software that you're not working on. But in our case, the trunk is just fine so we're going to do just a reverse integration from our branch and merge our changes from the branch into the trunk. So first, we're going to go look at the log to see which range of changes are correspond to our branch.

So in our case, you can see we created our branch at revision 6, now we added our update at revision 7. So first we have to get back to the root directory of our project and then we're going to use the svn merge Command, so we tell it to merge all the versions we have done in the branch. So svn merge -r6:7 branches\b1 trunk. As before note that this does not actually record those changes in the repository, we still have to check those in.

But now you can see instead of M for modified, it has U for updated and from merging, and it shows you that it's merging and recorded a merge info for that. So now we're going to say svn ci Merged changes from branch\b1 into trunk, and there we can see revision 8 we have merged changes form branches b1 into trunk. And our new feature is now in the trunk, and we can prove that by going into the trunk and typing out f1.c.

And you can see that we have both our original change and the feature. Okay, that's the basics of branching and merging. Obviously, you can get a lot more complicated than that, and you can find yourself in situations where there are conflicts, and you'll have to manage them manually using differencing tools. But it just shows you it's not hard to do branches, and it's not difficult to merge the changes back together if you properly coordinate what it is you're doing. Typically, there is going to be two different kinds of branches. You're going to do either a fix branch or a feature branch.

What we did here was a feature branch, but sometimes you might just take the current state of your product, make a branch in order to a fix, and then merge that fix back into the product while someone else continues on working on the main branch to do future things. All right, we're done with subversion in the command-line, let's move on to taking a look at subversion in shell integration using TortoiseSVN.

Show transcript

This video is part of

Image for Fundamentals of Software Version Control
Fundamentals of Software Version Control

49 video lessons · 12949 viewers

Michael Lehman
Author

 
Expand all | Collapse all
  1. 2m 12s
    1. Welcome
      56s
    2. What you should know before taking this course
      23s
    3. Using the exercise files
      53s
  2. 25m 8s
    1. Overview of software version control
      2m 51s
    2. Understanding version control concepts
      5m 14s
    3. Demo one: Getting started
      11m 1s
    4. Demo two: Handling the "oops"
      6m 2s
  3. 11m 3s
    1. The history of version control
      3m 44s
    2. Terminology
      4m 27s
    3. Exploring centralized vs. distributed systems
      2m 52s
  4. 28m 42s
    1. Getting files in and out of a repository
      4m 38s
    2. Saving changes and tracking history
      2m 47s
    3. Reverting to a prior version
      1m 42s
    4. Creating tags and labels
      1m 5s
    5. Branching and merging
      4m 10s
    6. Exploring workflow integration and continuous builds
      2m 46s
    7. Using graphical user interface (GUI) tools
      2m 39s
    8. Integrating a version control system with an integrated development environment (IDE)
      2m 50s
    9. Examining shell integration
      3m 26s
    10. Looking at forward and reverse integration
      2m 39s
  5. 25m 59s
    1. Installation and setup
      3m 31s
    2. Creating a repository and a project
      5m 10s
    3. Working with check-in, checkout, and revert
      6m 12s
    4. Tagging
      1m 34s
    5. Branching and merging
      5m 32s
    6. Working with GUI clients and IDE integration
      4m 0s
  6. 16m 13s
    1. Installation and setup
      55s
    2. Working with check-in, checkout, and revert
      9m 34s
    3. Tagging
      1m 7s
    4. Branching and merging
      4m 37s
  7. 26m 41s
    1. Installation and setup
      3m 47s
    2. Creating a repository and a project
      6m 15s
    3. Working with check-in, checkout, and revert
      8m 31s
    4. Tracking history and tagging
      2m 15s
    5. Branching and merging
      5m 53s
  8. 19m 25s
    1. Installation and setup
      3m 1s
    2. Creating a repository and a project
      1m 6s
    3. Working with check-in, checkout, and revert
      6m 39s
    4. Tagging
      2m 13s
    5. Branching and merging
      3m 44s
    6. Working with GUI clients and IDE integration
      2m 42s
  9. 16m 54s
    1. Installation and setup
      1m 48s
    2. Creating a repository and a project
      59s
    3. Working with check-in, checkout, revert, and tracking history
      6m 9s
    4. Tagging
      1m 50s
    5. Branching and merging
      4m 29s
    6. Exploring GUI and shell integration
      1m 39s
  10. 3m 38s
    1. Selecting a software version control that is right for you
      2m 30s
    2. Next steps
      1m 8s

Start learning today

Get unlimited access to all courses for just $25/month.

Become a member
Sometimes @lynda teaches me how to use a program and sometimes Lynda.com changes my life forever. @JosefShutter
@lynda lynda.com is an absolute life saver when it comes to learning todays software. Definitely recommend it! #higherlearning @Michael_Caraway
@lynda The best thing online! Your database of courses is great! To the mark and very helpful. Thanks! @ru22more
Got to create something yesterday I never thought I could do. #thanks @lynda @Ngventurella
I really do love @lynda as a learning platform. Never stop learning and developing, it’s probably our greatest gift as a species! @soundslikedavid
@lynda just subscribed to lynda.com all I can say its brilliant join now trust me @ButchSamurai
@lynda is an awesome resource. The membership is priceless if you take advantage of it. @diabetic_techie
One of the best decision I made this year. Buy a 1yr subscription to @lynda @cybercaptive
guys lynda.com (@lynda) is the best. So far I’ve learned Java, principles of OO programming, and now learning about MS project @lucasmitchell
Signed back up to @lynda dot com. I’ve missed it!! Proper geeking out right now! #timetolearn #geek @JayGodbold
Share a link to this course

What are exercise files?

Exercise files are the same files the author uses in the course. Save time by downloading the author's files instead of setting up your own files, and learn by following along with the instructor.

Can I take this course without the exercise files?

Yes! If you decide you would like the exercise files later, you can upgrade to a premium account any time.

Become a member Download sample files See plans and pricing

Please wait... please wait ...
Upgrade to get access to exercise files.

Exercise files video

How to use exercise files.

Learn by watching, listening, and doing, Exercise files are the same files the author uses in the course, so you can download them and follow along Premium memberships include access to all exercise files in the library.


Exercise files

Exercise files video

How to use exercise files.

For additional information on downloading and using exercise files, watch our instructional video or read the instructions in the FAQ .

This course includes free exercise files, so you can practice while you watch the course. To access all the exercise files in our library, become a Premium Member.

Are you sure you want to mark all the videos in this course as unwatched?

This will not affect your course history, your reports, or your certificates of completion for this course.


Mark all as unwatched Cancel

Congratulations

You have completed Fundamentals of Software Version Control.

Return to your organization's learning portal to continue training, or close this page.


OK
Become a member to add this course to a playlist

Join today and get unlimited access to the entire library of video courses—and create as many playlists as you like.

Get started

Already a member ?

Become a member to like this course.

Join today and get unlimited access to the entire library of video courses.

Get started

Already a member?

Exercise files

Learn by watching, listening, and doing! Exercise files are the same files the author uses in the course, so you can download them and follow along. Exercise files are available with all Premium memberships. Learn more

Get started

Already a Premium member?

Exercise files video

How to use exercise files.

Ask a question

Thanks for contacting us.
You’ll hear from our Customer Service team within 24 hours.

Please enter the text shown below:

The classic layout automatically defaults to the latest Flash Player.

To choose a different player, hold the cursor over your name at the top right of any lynda.com page and choose Site preferences from the dropdown menu.

Continue to classic layout Stay on new layout
Exercise files

Access exercise files from a button right under the course name.

Mark videos as unwatched

Remove icons showing you already watched videos if you want to start over.

Control your viewing experience

Make the video wide, narrow, full-screen, or pop the player out of the page into its own window.

Interactive transcripts

Click on text in the transcript to jump to that spot in the video. As the video plays, the relevant spot in the transcript will be highlighted.

Learn more, save more. Upgrade today!

Get our Annual Premium Membership at our best savings yet.

Upgrade to our Annual Premium Membership today and get even more value from your lynda.com subscription:

“In a way, I feel like you are rooting for me. Like you are really invested in my experience, and want me to get as much out of these courses as possible this is the best place to start on your journey to learning new material.”— Nadine H.

Thanks for signing up.

We’ll send you a confirmation email shortly.


Sign up and receive emails about lynda.com and our online training library:

Here’s our privacy policy with more details about how we handle your information.

Keep up with news, tips, and latest courses with emails from lynda.com.

Sign up and receive emails about lynda.com and our online training library:

Here’s our privacy policy with more details about how we handle your information.

   
submit Lightbox submit clicked
Terms and conditions of use

We've updated our terms and conditions (now called terms of service).Go
Review and accept our updated terms of service.