17

I've never really worked with a lot of people where we had to check out code and have repositories of old code, etc. I'm not sure I even know what these terms mean. If I want to to start a new project that involves more than myself that tracks all the code changes, does "check out" (again, don't know what that means), how do I get started? Is that what SVN is for? Something else? Do I download a program that keeps up with the code?

What do I do?

It will all be in house. No Internet for storing code.

I don't even know if what I am asking for is called source control. I see things about checking out, SVN, source control, and so on. I don't know if it is all talking about the same thing or not. I was hoping to use something open source.

Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
johnny
  • 19,272
  • 52
  • 157
  • 259
  • 6
    Source control is also very useful for one-developer projects -- you'll see once you get to know it. – Arjan May 01 '09 at 17:26
  • 1
    Subversion is open source, as are git andd mercurial. –  May 01 '09 at 17:41
  • As your other questions are mostly Windows based: what IDE are you using? Though integration in the IDE is not a requirement to use some source control, it surely helps. In fact, doing all my daily CVS and SVN things in Eclipse, I hardly do any command line things anymore. CVS and SVN integration in Eclipse is good (though the latter needs a plugin) so CVS and SVN are good choices for my projects, but I don't know about other IDEs. – Arjan May 01 '09 at 21:59

5 Answers5

37

So, a long time ago, in the bad old days of yore, source control used a library metaphor. If you wanted to edit a file, the only way to avoid conflicts was to make sure that you were the ONLY one editing the file. What you'd do is ask the source control system to "check out" that file, indicating that you were editing it and nobody else was allowed to edit it until you made your changes and the file was "checked in". If you needed to make a change to a checked out file, you had to go find that freakin' developer who'd had everythingImportant.conf checked out since last Tuesday..freakin' Bill...

Anyway, source control doesn't really work like that anymore, but the language stuck with us. Nowadays, "checking out" code means downloading a copy of the code from the code repository. The files will appear in a local directory, allowing you to use them, compile the code, and even make changes to the source that you could perhaps upload back to the repository later, should you need to. Even better, with just a single command, you can get all the changes that have been made by other developers since the last time you downloaded the code. Good stuff.

There are several major source control libraries, of which SVN (also called Subversion) is one (CVS, Git, HG, Perforce, ClearCase, etc are others). I recommend starting with SVN, Git, or HG, since they're all free and all have excellent documentation.

You might want to start using source control even if you're the only developer. There's nothing worse than realizing that last night the thousand lines of code you deleted as useless were actually critically important and are now lost forever. Source control allows you to zoom forwards and backwards in the history of your files, letting you easily recover stuff that you should not have removed, and giving you a lot more confidence about deleting useless stuff. Plus, fiddling around with it on your own is good practice.

Being comfortable with source/revision control software is a critical job skill of any serious software engineer. Mastering it will effectively level you up as a professional developer. Coming onto a project and finding that the team keeps all their source in a folder somewhere is an awful experience. Good luck! You're already on the right path just by being interested!

Brandon Yarbrough
  • 37,021
  • 23
  • 116
  • 145
20

Check out Eric Sink's excellent series of articles:

Source Control HOWTO

Gulzar Nazim
  • 51,744
  • 26
  • 128
  • 170
  • 1
    Looks promising so far. I hope it will provide an open source solution instead of the product he sells. Thank you (everyone). – johnny May 01 '09 at 17:35
  • 1
    there are plenty open source solutions for source revision control (CVS, Subversion, GIT, etc...). Eric's articles are great resources for what it is, which is where you are starting. – kenny May 01 '09 at 17:38
2

I recommend Git and Subversion (SVN) both as free, open-source version control systems that work very well. Git has some nice features given that it can be easier to work decentralized.

Scott Arrington
  • 12,325
  • 3
  • 42
  • 54
  • If I check out my code from Subversion, I certainly don't get exclusive access to anything. –  May 01 '09 at 17:31
  • 2
    That's one meaning of "check out", but it's getting increasingly old-fashioned. The more common meaning is that you get a copy of everything you need, regardless of what anybody else has. Modern VCSes are not designed to work with exclusive access, although some of them have some provision for it. – David Thornley May 01 '09 at 17:33
  • Why wouuld they move from what he put? It sounds good to have exclusive control How else would you keep from writing over each other? (just trying to understand.) – johnny May 01 '09 at 17:36
  • See the link in my answer for why non-exclusive control works. In practice, I have found it much more productive. Sometimes you spend time fixing a conflict, but much less time than you spend waiting around for someone to release a file. Especially when they went on vacation for two weeks and forget to release all their locks, or even worse, couldn't because they were in the middle of a difficult change that couldn't go back into the code, they couldn't lose, and making a copy was too much of a hassle. – Yishai May 01 '09 at 17:45
  • Not to mention that breaking locks is trivial in Subversion: "svn unlock --force foo.html". – John Feminella May 01 '09 at 18:19
2

Checkout means retrieving a file from a source control system. A source control system is a database (some, like CVS, use just specially marked up text files, but a file system is also a database) that holds all versions of your code (that are checked in after you make modifications).

Microsoft Visual SourceSafe uses a very proprietary database which is prone to corruption if it is not regularly maintained and uses reserved checkouts exclusively. Don't use it, for all those reasons.

The difference between a reserved checkout and an unreserved checkout is in an unreserved checkout; two people can be modifying the same file at once. The first one to check in gets in no problem, and the second one has to update their code to the latest version and merge the changes into theirs (which usually happens automatically, but if the same area of the file was changed, then there is a conflict, which has to be resolved before it can be checked in).

For some arguments for unreserved checkouts, see here.

Following this, you will be looking at a build process that independently checks out the code and builds the source code, so that everyone's changes are built and distributed together.

Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
Yishai
  • 90,445
  • 31
  • 189
  • 263
1

Are you creating the project that requires source control? If so, choose a source control system that meets your needs, and read the documentation for how to get it set up. If you are simply using a previously set up source control system for an existing project, ask a coworker who has been using it, or ask the person who set up the source control system.

For choosing a source control system that meets your needs, most source control systems have extensive descriptions of their features online, many provide evaluation or even completely free products, and there are many many many anecdotal descriptions of what working with each individual source control system is like, which can help.

Just don't use Microsoft Visual SourceSafe if you value your sanity and your code.

Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
Paul Sonier
  • 38,903
  • 3
  • 77
  • 117
  • Bear in mind that you can get excellent VCS tools for free, that are fairly easy to set up. The only reason for using one that's less than excellent is if it's already installed and in use. – David Thornley May 01 '09 at 17:36
  • About the only files that you'd want an exclusive lock on these days are binary files (e.g., database files or bitmaps); and most SCMs these days will automatically do an exclusive lock on file types that they treat as binaries and a non-exclusive lock on other file types. Most SCMs these days have decent merge facilities for text based files for those cases where two or more devs have the same file locked and one wants to check it back in after another has checked his/her changes in. – RobH May 01 '09 at 18:57