Easy-to-follow video tutorials help you learn software, creative, and business skills.Become a member
The first thing you need to know to use Version Control is how to create either the entire repository or how to create a portion of the repository for the project you're working on. For a Centralized Version Control, most often the repository itself is created for you by your system administrator. With Distributed Version Control, you'll create the repository yourself at least on your local machine. And then you may synchronize it with another repository created on the server by an administrator. So you create the repository by using a command that's sometimes called initialize and sometimes called create.
And what this does is create an empty space for you to put your files and directories in, as we did in our sample before where we simply created myprog.c and checked it in. If your files already exist, meaning you're adding an existing project to Version Control, you can use the Add feature of your Version Control Software to bulk add all the files and directories into your working set and then check them in. In Distributed Version Control, there's usually a concept between your file system and the repository that's called the staging area.
So, when you actually do an add, the files go from your working set into the staging area and then from the staging area into the repository, because 99% of the time, the concept of using the staging area as two steps is more than you actually need, as we did in the previous demos. I did git commit -a -m and the -a meant add any files that are in the working set that aren't already in the repository automatically.
So I could do that commit as a single step. Now of course, once you've got your files in, you want to get them back out in order to be able to work on them. And depending on the type of Version Control System you're using, whether it's Centralized or Distributed, you may be required to tell the Version Control System that you're going to start making changes to the files. Most centralized systems have the concept of check out. This means that you are telling the Version Control System that you are going to work on this file. So it will actually lock the file so other people cannot make changes until you check it back in.
So, version Perforce and TFS allow you to specify which kinds of files, and which files require a lock on checkout, and which files don't. For example, you would typically require a lock on files that are non-textual, like images, or Zip files, or audio recordings, because the Version Control System can't easily detect the subtlety of a change in one portion of an image that you make and a change in another portion of an image that someone else makes and actually merge them together.
So, if the files are not locked on checkout, then you might end up with conflicts when you check them back in. So, the reason that the centralized systems put the lock on there is to make sure that it's easy to make sure that reduces the number of conflicts and the number of problems you have checking in and merging. So for example, if Joe makes changes to a file, and then Arlene also makes changes to the same file, Joe can check his file, and then later when Arlene tries to check in, the server says that the changes conflict, and she ends up doing a manual differencing in order to resolve these things.
TFS in particular has a feature called shelving which allows you to check out files and lock them, and then if you're not finished working on them before somebody else needs to make a change, you are going to actually take all the files you have checked out and put them in to what's called a shelf set, and essentially puts them up on the shelf so that the files can be unlocked and other people can work on it and then you can take your shelf set off the shelf, put it back into your working set, and do some more changes and then check in, because your changes don't necessarily conflict with what somebody else needed to do.
But since the system actually locks the files, you may want to make sure that the person who needs to get in there can actually make those changes when they need to. Distributed Version Control Systems like Git and Mercurial specifically have made the concept of branching super lightweight. When you say git branch, it actually simply creates one extra file, and doesn't make literally a second copy of the entire directory in your working set. And when using Git and Mercurial in a team, the workflow is usually instead of locking the files, you actually branch the entire repository, make your changes, and then merge back in because it's such a lightweight process.
We'll dig into more about that when we talk about branching and merging and when we demonstrate branching and merging in Mercurial and Git.
Get unlimited access to all courses for just $25/month.Become a member
82 Video lessons · 101341 Viewers
61 Video lessons · 88099 Viewers
71 Video lessons · 71950 Viewers
56 Video lessons · 103769 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.