views:

624

answers:

19

Possible Duplicates:
Do I really need version control?
Using Version Control for Home Development

I was reading a blog where the writer said this

"Code doesn’t exist unless it’s checked into a version control system. Use version control for everything you do. Any version control, SVN, Git, even CVS, master it and use it."

I have never used any sort of version control and I do not find it that great. I have googled it and looked at it before, but I just need it put into children's terms if you will please.

As I understand it right now, things like SVN are for storing your code online for a group of users or other developers to have access to the same code. Once you update some code, you can submit the new version and the SVN will keep copies of old code as well as the new ones you update.

Is this the basic idea of it or am I getting it completely wrong?

If I am right, then it might not be much use if I:

  • Do not have other people working on the code.
  • Do not plan on letting others have the code.
+4  A: 

You gain security (in the sense of having a back-up of your code) and versioning of your code (assuming you get into a habit of committing your changes often). Both are very good things even if nobody else ends up ever working on the code with you...

+1  A: 

It is also about backing up old file that why it is called "Subversion". So you can manage multiple version of your work in which you can return back (revert) and manage the different implementation of it (branching).

NawaMan
+4  A: 

Even as a single developer source control offers a great benefit. It allows you to store your code's history and revert back to previous versions of your software at any time. This allows you fearless flexibility to experiment because you can always restore to another version of your source code that was working.

It's like having a giant "undo" button all the way back to your first line of code.

gbc
+3  A: 

Version control is great for checking previous versions, even if you're working alone. For example, if you accidentally delete code or a file you can get it back; or you can compare previous versions to see why a new bug has crept in. It's also good if you're one person working in multiple locations.

My personal favourite is git.

Peter
subversion works too!
bentford
+12  A: 

Even if you work alone you can benefit from source control. Among others, for these reasons:

  • you don't lose anything. I never again commented code. I simply delete it. It doesn't clutter my screen, and it isn't lost. I can recover it by checking out an old commit.

  • you can experiment at will. If it doesn't solve the problem, revert it.

  • you can look at previous versions of the code to find out when and where bugs were introduced. git bisect is great in that regard.

  • more "advanced" features like branching and merging let you have multiple parallel lines of development. You can work in two simultaneous features without interference and switch back and forth without much hassle.

  • you can see "what changed". This may sound basic, but that's something I find myself checking a lot. I very often begin my one-man workflow with: what did I do yesterday?

Just go ahead and try it. Start slowly with basic features and learn others as you go. You will soon find that you won't ever want to go back to "the dark ages" of no VCS.

If you want a local VCS you can setup your own subversion server (what I did in the past), but today I would recommend using git. Much simpler. Simply cd to your code directory and run:

git init

Welcome to the club.

Martinho Fernandes
that does sound nice, so it can be local and doesn't have to be on the web for anyone to see? I use php designer, I love it and it has integration for Tortoise SVN, not sure if that is a good one
jasondavis
just use anything at all to start with - then after a while when you know a bit, read up on alternatives and try one of them out, then another and so on
1800 INFORMATION
+1 for the bullet on never commenting out code
Ed Schembor
+7  A: 

Version control is a rare tool that I would say is absolutely required, even if you are only using it as a solo developer. Some people say that it's a tool that you live and die by, I agree with that assertion.

You probably use version control right now, even if you don't know it. Do you have any folders that say "XXX Php Code (December)" or "XXX.php.bak.2"? These are forms of version control already. A good version control system will take care of this for you automatically. You will be able to roll back to any point in time (that you have data checked in) and be able to see an exact copy of that data.

Furthermore, if you adopt a system like subversion, and use a remote repository (such as one on a server you own), you will have a place to keep all of your code. Need a copy of your code somewhere else? No problem, just check it out. Hard drive crash at home? Not an issue (at least with your source code).

Even if you don't use version control now, you will likely use it at one point in time later in your career and you could benefit from becoming more comfortable with the principles now.

Robert Venables
...or "Copy of Copy of Copy of MyWork"
spender
@spender: Exactly, that's what I remember from the dark days before I started using version control :-)
Robert Venables
It does sound very useful and my current project is somewhat large, at least 150-200 files, how does this work, i hear "version" doe that mean like version 1 and version 2, if the number increments, what if I modify 1 file and not the rest, will I have 200 copies of unmodified code or just copies of file that are modified?
jasondavis
Only the delta of your changes is stored, so if you change one line in one file, that is all that will be stored at that version. A file in version control can be thought of as the sum of all its changes
spender
+5  A: 

Version control is almost impossible to live without after you start using it. It is indispensible if more than one developers are working on the same code base...but it also quite useful for a single developer.

It tracks the changes in your code and allows you to roll back to previous versions. It frees you to experiment with the knowledge that if anything breaks you can undo your changes.

Vincent Ramdhanie
+32  A: 

Have you ever:

  • Made a change to code, realised it was a mistake and wanted to go back?
  • Lost code or had a backup that was too old?
  • Had to maintain multiple versions of a product?
  • Wanted to see the difference between 2 versions of your code?
  • Wanted to prove that a particular change broke or fixed some piece of code?
  • Wanted to submit a change (patch) to someone else's code?
  • Wanted to see how much work is being done (where and when)?
  • Wanted to experiment with a new feature without interfering with working code?

In all cases version control systems make your life easier.

To misquote a friend of mine: A civilised tool for a civilised age.

Si
A: 

You'll probably want something like subversion even if you're working by yourself so that you have a history of all your changes. You might want to see what a piece of code looked like once upon a time to remember why you made a change.

Having source control is also useful when you check in often. If you check in often, you'll always be in a state to roll back often too. Many times you could start going down one path to solve a problem and then realise it was the wrong path to go. Many times you could just keep barking down the wrong path and end up building a terrible solution - only because you didn't want to lose all your work. By checking in often, the last point of "happiness" is not far away so even if you go down the wrong path you can always roll back and try again and make a more elegant and simple solution. Which is always a good thing so you can understand and maintain what you wrote in the future.

digiarnie
A: 

You may find that you had a working version of your program.

You decide to add a few new features over a period of time and you release that.

You start getting bug reports affecting some code that you thought you didn't touch.

By using SVN, for example, you can move back to an older version, and check to see if the new bug exists. Once you find a version that introduced the bug it will be easier to fix it as you can compare the version that worked to what didn't work and see what changed, then it will narrow down the search.

Source control has many uses, even if you are the only developer.

James Black
+1  A: 

The fact that other developers participate or not is totally orthogonal to the need of a version control system.

You can be the only developer but still will benefit from:

  • a history trail of all your changes
  • ability to go back and forward on that history
  • ability to experiment with the source and while still having a working version (branching)
  • a backup copy (especially if you use a different machine as the source control server, and even more if that machine is regularly backed up)

Now, if you have a group developing on the same codebase version control is still more necessary so

  • people can edit the same file at the same time (depending on the particular system, but most sane ones allow you to do this)
  • you can tell who did what to the code when

When there is more people involved it is more relevant which version control tool you pick, depending on the style of development.

Vinko Vrsalovic
A: 

Sounds like you're looking for something a bit more light-weight. Check out Mercurial (awesome reference book). I use it for everything, from source code to personal correspondence.

Some benefits:

  • Giant Undo button, so you can return the those halcyon days of last week when the code actually ran
  • Throw-away code. Not sure if this is the best way to do something? Make a branch and experiment. Nobody but you ever has to know about it if you're using a DVCS like mercurial.
  • Syncronized development. I develop on 4 different computers. I push and pull between them to keep the current, so no matter which one I'm at I've got the newest versions.
Jonathanb
+1  A: 

There are a number of reasons to use version control, even if you are the only person who will ever touch the code.

  • Backup - what if your hard-drive crashes? Do you have a copy anywhere?
  • Revision history - Do you currently keep copies of code in different folders? Version control gives you the ability to track your changes over time and easily diff different revisions, merge, roll back changes, etc. using tools.
  • Branches - the ability to test out some changes, still track what you are doing, and then decide whether or not you want to keep it and merge into the main project or just throw it away.

If you keep your code under version control, then it makes it really easy to see which files you have changed (or have forgotten to add to the baseline).

Mads Hansen
A: 

Even if you haven't been in a situation yet where you needed an older version of your program, having a source control gives you greater confidence to make major changes.

I found myself doing more aggressive refactoring after using source control because I always knew that a working version could be easily restored.

Otto Allmendinger
A: 

It depends on the size of the project and how often you change your mind about parts of it. For small projects where you're just getting something done in a linear fashion, version control is probably not going to be of much help (though if you accidentally delete or corrupt a file without version control, you'll be crying).

But a couple of weeks ago I met a friend who was writing an enormous hobby project on his own. He had ten or twenty copies of his code, with suffixes like "X1", "X2", "test", "faster" and so forth.

If you've made more than two copies of your code, you need version control. A good version control system lets you undo a change you made a while ago without undoing the stuff you did after making that change. It lets you see when certain changes were made. It lets you split your code into two "paths" (e.g. one for testing out a new idea, the other to keep your "tried and trusted" code safe until you've finished testing) and then merge them back together.

Artelius
A: 

I have also only recently begun to get interested in version control. In version control systems, you have the concept of a repository for your code. A wealth of new shell commands get learned very quickly so that you can interact with this repository.

Once you save your code to a file, you can then commit this to your project's repository. As you develop your code and commit your changes the repository develops a series of revisions. You can access any of these by checking out a revision. If you work alone it's unlikely that you'll be doing much checking out unless you lose your code files or want to work on a different machine. In these cases you'll usually check out the latest revision of all files.

For my own part, i no longer keep files or folders named 'project_old' when I decide to refactor something. Any changes I make are stored incrementally and I will always be able to step backwards to a project that worked as a whole. I rarely use FTP to deploy now because I just checkout my code through ssh. Only the files I've changed are downloaded and if I need to reload on the server the terminal is already there.

I found this talk on GIT to be really instructive; http://www.youtube.com/watch?v=4XpnKHJAok8

It's a google talk where Linus Torvalds makes an argument for using one version control system over another. In doing so he explains how they work using concepts and then compares different ways of implementing them.

deau
A: 

Something that no one else seems to have explicitly mentioned is the tagging or labeling of releases. If you have a client using version 1 of your software and you're busy working on version 2 what do you do when the client reports a bug and you need to build version 1.1?

A source control system will let you label every release you make so you can go back to it later, make the fix (and merge that fix into the new version 2 code) and make a new release without worrying that you might accidentally deliver something that isn't ready.

Source control is a core part of modern software development. If you're not using it (even for personal projects as the more experience you have the better) you're doing something wrong.

Usually one of the first questions I ask when being interviewed for a job is "What do you use for source control?" So far only one place has said "Nothing" but they were planning to fix that "Real soon now..."

forgot my open id login
A: 

Perhaps you should be asking why everyone uses source control. They can't be all wrong.

mP
+2  A: 

Even working alone, has this ever happened? You run your app, and something does not work and you say "that worked yesterday, and I swear I did not touch that class/method." If you are checking in code regularly, a quick version diff would show exactly what had changed in the last day.

Ed Schembor