Start learning with our library of video tutorials taught by experts. Get started
Viewers: in countries Watching now:
This course is a gateway to learning software version control (SVC), process management, and collaboration techniques. Author Michael Lehman reviews the history of version control and demonstrates the fundamental concepts: check-in/checkout, forking, merging, commits, and distribution. The choice of an SVC system is critical to effectively managing and versioning the assets in a software development project (from source code, images, and compiled binaries to installation packages), so the course also surveys the solutions available. Michael examines Git, Perforce, Subversion, Mercurial, and Microsoft Team Foundation Server (TFS) in particular, describing the appropriate use, features, benefits, and optimal group size for each one.
Okay, we've got a repository, we've got a project, we've got a Visual Studio project, let's add some files and check it in. So in this case, we're going to right-click on the project here and come down to the Add menu and select Add > Class, and we're going to call this class f1.cs, and here's our class. So inside our class, we're going to add a function. The content is from the new project's Haiku error message page. We're going to pick one that's happened to all of us before we started using Version Control. So let's come down here and add void func1 (), and we will use Console.WriteLine, which is the C# equivalent of printf, With searching comes loss, and the presence of absence, My novel\" not found.
Now let's look at the Solution Explorer and see what Visual Studio is telling us. We can see for ConsoleApplication1, there's a red check mark next to it. That means that file has been updated and still needs to be checked in. You can see that f1.cs has a green plus sign next to it. That means that's a file to be added to Version Control, but not yet checked in. And as we saw before, for example, Program.cs has a little blue lock icon next to it, which means it's checked in, it's read-only in your working set until you start making some changes to it, which also means that your working set for that file is up to date with your repository.
So in order to check this in, we're going to come over here and right-click on the project line, ConsoleApplication1, and then we're going to select Check In from the menu. Visual Studio of course always requires you to save everything before you check it in, so we'll say Yes. Now it brings us back to the Pending Changes tab. So we can see a number of things here. We can see we're in our Team Project TFS1, and you can see exactly all the details when I hover over that. You can see that there are two changes here, and you can see this tree, this shows which files are being changed.
You can see that ConsoleApplication1.csproj is being updated, and f1.cs is being added. So in our Comments, we're going to say Add Func1, and then we're going to click the Check In button, and now we see Changeset 11 successfully checked in. Let's go back to our Source Code Control Explorer and look a little bit at the status of what's going on here. We can come to this folder now and right-click and say View History. Now we can see for, as we did with Git in our initial run-through, this is essentially the same as a Git log, so here at Changeset 10, we did an Initial Commit, Changeset 11, we added function 1.
You can right-click here and ask for Changeset Details, and over here you'll see we added f1.cs and updated csproj. If we click on this one and say Changeset Details, the Team Explorer now shows us the fact that we added all these files. So let's close the History pane. Let's go back to our f1.cs, and let's go back to our Solution Explorer. So let's make a change so that we can see versioning in action. So we're going to open this file again, and we're going to make a change, we're going to change the string My Novel to Website. Now we're going to save the file.
This button here saves the individual file, this button here saves everything, so I tend to get into a habit of clicking this Save All before I do Source Code Control operations in order to save me all those dialogues of, oops, you forgot to save that. So once again, we'll come over here, right-click, and say Check In. Once again, the Pending Changes dialog pops up, and we're going to say Changed My Novel to Website and click Check In. But before we click Check In, I want to make a note of something that TFS does uniquely from some of the other Source Code Control systems.
Because TFS locks the files, when you check them out to edit, sometimes somebody needs to go in and make a change to a file before you're ready to check in, and when you need to do that, what you do is you use this Shelve feature. So the Shelve feature allows you to preserve your Pending Changes and add this to what's called a Shelf Set, which is essentially a temporary Check In, so all your work is saved in the central server, but the mainline is not physically changed so that someone else can check that out and make their changes.
So in this case, we're not going to do a Shelve, we're going to click Cancel. We're going to come back and actually do the check in, but that feature can be incredibly handy when you have a system like this, which has a centralized server, and file locking. All right. Now we've got Changeset 12 checked in. Once again, we'll come back to the Source Code Control Explorer and ask for History, and there you can see, here is our initial Changeset, Add Func1, Changed My Novel to Website. If we select two Changesets, for example, 12 and 11, we can now right-click and say Compare.
This dialog pops up because you get all kinds of options when doing compares, we won't get into all the details of that, but this also can work when you've got lots and lots of files, you can filter by specific file types and so forth. In this case, we're just going to click OK and look at the differences, and you can see, ah, these two things are different. And if we compare the files now, it will actually give us a visual comparison, and we can see that My Novel got changed to Website. Note that a Changeset, of course, can contain potentially hundreds of files or thousands of files, if you've been working on it for days and weeks.
So the Changeset first gives you the level of folder differences, because you might have additional folders being added and deleted, and then once you've come to that level, as. As we saw back here, you can actually then compare individual files. So we'll close this and we'll close this and continue on. Now, let's make another change. We'll close the History, come back to our file, and we're going to change Website to Webpage. Now, we're not going to check it in, but we are going to try to ask for the differences.
So we're going to come back to the Solution Explorer, and we're going to right-click here, and we're going to compare, and we're going to compare our Workspace Version with the Latest Version, so we click OK. And again, we get the visual differencing window here, and you can see that it says that the server version has Website and our currently updated version that's not yet checked in has Webpage. So in this case, in order to revert this, all we have to do is close this and come back to Visual Studio and say Undo.
Now, let's go ahead and update that again to Webpage and save it. So if we look over in the Solution Explorer, we can see that f1.cs now has a red check mark next to it. But what if we decided after we've saved it in our local working set, but before we've checked it into TFS, that this isn't really what we want to do? Well, you can come over here, right-click on the file, come down to the Source Code Control menu, and say Undo Pending Changes. You will get this dialog that says this is going to undo all pending source changes for that particular file or files that you've selected.
I'm going to click Undo Changes, and it says Undo check-out and discard changes? I'm going to say Yes to All, and now you can see that Webpage has now been reverted to Website. Remember, none of your changes in the repository have been lost. You're just updating the working set. If we go to this file, come down here, and Source Code Control, and say View History, we can actually completely revert back to this one if we want to. We can say Get This Version or Rollback Entire Changeset.
So Get This Version will allow us, for example, to say, all right, now I want to have that version which still had My Novel in it. Remember, you haven't lost anything. We can come back up here and say Get This Version, and now we're back to Website. So that's the basic workflow when working with files in TFS. You simply edit the files, Visual Studio automatically checks things out, you Check In using the Pending Changes window, and you use the History window to be able to do differencing and to be able to revert to other Changesets.
Now let's move on and take a look at labeling in TFS, and then after that, we'll look at branching and merging.
There are currently no FAQs about Fundamentals of Software Version Control.
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.