views:

142

answers:

5

I'm not sure how to do this. I just started using SVN on a real project. I have everything working correctly. But, I'm the only one using it. Now I want to introduce a second person to the process.

I downloaded tortoisesvn on my windows machine and did a checkout of the main trunk. I can edit a file and commit my new file. Everything works.

Now, I want the second guy to do it, while I am doing something. Usually he might be working on another file and we would agree on a time to export our committed files to the test server (my thought anyway), but what if we are working on the same file? for example, a config file. Maybe we both need to change it. How can I (or he) keep the other one out of it while someone else changes it. If one of us commits a new update it will erase what one of us has just put in. Not sure what to do here.

+9  A: 

With SVN, the goal is not to grab a file and say "This is mine, don't touch it". The goal is to MERGE your changes when you are both finished. The number of cases where two people are truly making incompatible changes are small and when they happen, the developers need to get together on the best way to merge them - as opposed to having a race to who wins the file lock first.

Always Update before Commit, so that you merge in their changes with yours.

Russell Steen
But if I hit update wont't that erase what I just did? I thought update updated my files on the dev box with what is on the server.
johnny
It won't erase, it will create a conflict which you will need to resolve.
Russell Steen
Yes, it updates your files, but it does not erase what you just did. If your changes do not overlap, then SVN simply puts the changes into your copy automatically. If your changes do overlap, that is called a conflict, and SVN will put both your text and the other text into the same file, and it will be necessary for you to manually "fix" it.
Kevin Panko
+6  A: 

No, it will not erase anything.

If two people change a file and try to commit it, the second person to commit will get an error message saying the file has been changed since their last update.

That second person then does an update. If SVN can do so, it will merge them, preserving the changes of both people. If it cannot (usually only the case if you change something in the same place in the file), it will tell you and you will have to handle the conflicts.

Michael Madsen
One tip, try to commit often. Thus reducing the chances and severity of conflicts.
NomeN
Yes, but not too often. Wait until you get to a point where you have things working, and your changes are "ready." You do not want to commit every 10 minutes, and you do not want to wait 6 weeks either. A rule of thumb is to commit one unit of work, i.e. one new feature or one bug fix.
Kevin Panko
+2  A: 

This problem cannot occur because Subversion (any decent SCM actually) will only let you commit AFTER you have performed an update. If Subversion cannot merge your changes, it will cause a conflict, which you have to resolve manually.

Christopher Oezbek
+2  A: 

SVN has locks in the rare case that you need to use them. Check out the Locking section of the SVN book for more details.

Rob Tanzola
http://svnbook.red-bean.com/nightly/en/svn.advanced.locking.html
Kevin Panko
+2  A: 

It sounds like you need a basic understanding of how SVN works. I suggest you read the section Versioning Models from the book.

RedFilter