Easy-to-follow video tutorials help you learn software, creative, and business skills.Become a member
The last major piece of functionality we need to explore in TFS is branching and merging. Now, branching and merging are done quite a bit differently in TFS than they are, say in Git or Mercurial. It actually creates new folders inside your project folder. So we'll come over here to our Sample and say right-click, create a Branch, and we'll call it branch1. Now, you can see that there are actually two separate physical sets of folders inside this and this.
You see it's created over here in the Folders section a new branch, and there's a little T symbol there that indicates that's a new branch. Like some of the other systems, the branch has been created, but it's not physically in the repository yet until we check it in. So we'll come over here to the Team Explorer, and we'll add a Comment, Create Branch1, and we'll check it in. So now we have our branch created, and you can see that the branch is actually stored in a completely separate folder, the branch is stored in our project folder under the folder TFSSample-branch1, whereas our original project is stored over here under FSVC1\ConsoleApplication1.
So in order to switch to the branch, we actually need to open up the appropriate Visual Studio solution for the files. So, for example, we'll come back to ConsoleApplication1, underneath branch1, and double-click on ConsoleApplication1.csproj. So now it looks like we're in the same place, except if we hover on top of the file name, you'll see that the full file name here says TFS1\ TFSSample-branch1\ ConsoleApplication1\f1.cs. So if we make a change here, instead of Node not found, we say Dwarf not found, and we save it, and we can check that in, Change node to Dwarf.
If we now come back to our Source Code Explorer and ask to View History, you see that we have a completely separate set of Changesets for the branch. Now, this is different again than the version Git and Mercurial in that there is a set of Changesets for each branch that are completely independent. So now if we want to switch back to our other branch, to the main branch, we can come here to ConsoleApplication1 and once again open up ConsoleApplication1.csproj, and you can see, not only we are back to Node, but if we hover here, you can see we're back in the FSVC1 directory.
So now let's do something in the branch so that we can actually have something to merge. We'll go back to our Source Code Control Explorer, go back to our ConsoleApplication1 in the branch, open up the project again. Now, we're not only going to change node to Dwarf, we're going to add another function, and then we're going to check this in, save it, check it in, and once again if we look at the History of our branch, you can see we have our Add func2.
Now let's go back to the Source Code Control Explorer, let's go back to this original main branch, open up that project. Then we are going to come back to the Source Code Control Explorer, and we're going to merge. So we right-click on the name of the folder, come to Branching and Merging and select Merge. Now it's going to ask us what we want to merge with, and it's really clear here that it allows you to decide which way you want to go. Now, in on our case, this merging is wrong direction. This says right here the way it's configured now, that would be merging our main branch into branch1.
We want to go the other direction. So we'll use Browse and select branch1 as the Source, and you can see it automatically updated the target branch, because TFS is smart enough to know you only have two branches. If that weren't the case, we can come here and Browse and select the main branch. Now we'll click Next, and it asks us which type of merging do we want to do? Do we want to do it to the Latest Version or to a particular Changeset or Label or Date? In this case, we'll use the Latest Version. It says all necessary information has been collected, and it's getting ready to merge.
We click Finish button, and the merge is done. Now it tells us that our file has been modified outside the Editor, because the Editor had the version that was in the main branch, and when we did the update, it actually updated the file in our Working Set directory on disk, but hasn't actually updated the Editor, so we're going to say Yes, we want it to reload. And now when we come back to f1.cs, you can see, not only do we have Dwarf, because that was the change we made in the branch, we also have our function 2, so we've successfully merged back from our branch back to the main.
And if you recall our conceptual overview, this is called a reverse integration, we actually took what was in the branch and brought it back into the main. Now, if you're going to continue keep working in the branch over a long period of time, you'll want to make sure that you do a forward integration by doing that merge in the opposite direction from the main branch back to your private branch on a fairly regular basis, for example, weekly, to make sure that your private branch doesn't get too far out of date with changes that other people are making to the main branch.
That's actually it for TFS. Since we've used TFS only with the GUI, there isn't any movie for using GUI and shell integration, because TFS integration is all done completely inside Visual Studio. I hope you've liked the overview of TFS. Obviously, Microsoft has tons of additional documentation videos on Channel 9, lots of information on being able to understand how to more effectively use Team Foundation Server.
Get unlimited access to all courses for just $25/month.Become a member
82 Video lessons · 97526 Viewers
61 Video lessons · 84763 Viewers
71 Video lessons · 68945 Viewers
56 Video lessons · 101390 Viewers
Access exercise files from a button right under the course name.
Search within course videos and transcripts, and jump right to the results.
Remove icons showing you already watched videos if you want to start over.
Make the video wide, narrow, full-screen, or pop the player out of the page into its own window.
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.
Your file was successfully uploaded.