This video will talk about why it's a great idea to use a version control system in the first place. We learn concepts like how such a system backs up your data—which is a little different than a standard backup—how it helps you look at the history of your project, and how it helps you to collaborate with your team when your writing code.
- [Instructor] This course is an introduction to using the Subversion version control system with Java. Before we get started I think it's worth talking about version control systems in general, concepts that are common to various version control systems, and some of the differences too. At this point in time, the two most popular version control systems are probably Subversion and Git. With systems like Mercurial, and CVS running distant third. No matter which version control system you use, they all have similar concepts and methodologies, and it's good to get a basic understanding of these types of systems as a whole before we talk about the individual parts.
That's what this chapter is all about. While version control systems can be used to track changes on any kind of file, all the systems we're interested in were written with programmers in mind. They're geared towards managing the files used in software projects, and since this is a course for programmers, we'll be focused on using version control specifically to manage software development. So, what kinds of problems are version control systems trying to solve? At a very high level, a version control system allows you to store multiple versions of a file.
As you make changes to the file, you can store your changes in the version control system so you can easily go back and find old copies of that file. As a programmer, you tend to work on sets of files instead of a single, large, monolithic file. Your programs probably consist of source code files, configuration files, assets like graphics files, and other kinds of binary and text files. You can store all these together as projects in a version control system, so you can manage them and store them all as a group. This is more than just a way to backup your files though.
A version control system allows you to see the old files, but it can also show you what changed from one version of a file to the next, and when the file got changed. If you're working in a team, it will even show you who changed the file. Seeing what changed in a file can be useful in a lot of different circumstances. It can be especially helpful when you have code that used to work, and suddenly it doesn't, and you want to see what change broke the code. If you know when the code broke, or you know which file contains the broken code, a version control system makes it easy to study the changes and understand the problem.
If you do find a problem in your code, and you want to revert back to a previous good copy of the code, a version control system makes it trivial to back out your changes. All you have to do is switch back to an older revision of your files, and go from there. Since the version control system tracks all the changes in the central location, it's very easy to find the previous copies too. There's no need to search through backup drives to find what you're looking for. You just go straight to the version control system and everything is there in one place. Since it's easy to back out changes, and to see what changed, a version control system also gives you a lot more confidence if you want to try new things with your code.
Do you want to delete old chunks of code that you don't think are useful anymore? Do you want to completely rewrite entire classes and methods? Go ahead, make all the changes you want. If you find out later that you need that chunk of code you deleted, just select it from the version control system. If you decide that your rewritten code isn't going to work, or that the old code was better, just revert back to the previous version of the code. There's no more need to comment out large sections of old code, or save them in text files in case you need them again later. It's all in the version control system, available if you need it.
Lastly, a version control system makes it a lot easier to work on code as a team. It's one thing to work on a software project all by yourself, but trying to allow multiple people to all work on the same set of code at the same time is a daunting task. Version control systems are designed to make it a lot easier for teams to make changes to files. These systems have highly refined routines that can detect file differences, merge changes together, and flag changes that would conflict with each other. In fact, version control software is generally written by teams of people who are using their own version control software to manage their code, so the very people who write the software are constantly improving it and making it better, and finding out firsthand when things don't work like they should.
The rest of this chapter, we'll discuss some of the basic concepts of managing your code changes. We'll talk about repositories and project structures, like trunks, branches, and tags. We'll introduce you to checking out and committing your code, and how merges and revisions happen, and finally, we'll answer a few common questions that people have when they're getting started.
- Trunks, tags, and branches
- Checkout, commits, and revisions
- Merging, locking, and working with a team
- TortoiseSVN on Windows
- SVN integration with Eclipse
- Connecting to a project
- Creating a new Java project in Eclipse
- Connecting to an existing Java project using Eclipse
- Dealing with projects that move to a new location
- Making changes and creating branches
- Tracking changes and dealing with conflicts
- Creating a release