Presentation is loading. Please wait.

Presentation is loading. Please wait.

Subversion. What is Subversion? A Version Control System A successor to CVS and SourceSafe Essentially gives you a tracked, shared file system.

Similar presentations


Presentation on theme: "Subversion. What is Subversion? A Version Control System A successor to CVS and SourceSafe Essentially gives you a tracked, shared file system."— Presentation transcript:

1 Subversion

2 What is Subversion? A Version Control System A successor to CVS and SourceSafe Essentially gives you a tracked, shared file system

3 How does Subversion Work? 1. Create a repository 2. Import files 3. Checkout into Working Directory 4. Make Changes 5. Commit back to Repository 6. Update MY REPOSITORY File 1File 2File 3 My Working Dir File 1File 2File 3 Your Working Dir File 1File 2File 3File 1File 2 File 3 File 1 File 2 File 3 File 2 File 1 File 3

4 Importing Into A Repository Add any directory to a repository The source directory does not become a working directory or a repo Directories typically structured with three subdirectories: trunk, branches, tags ls branches tags trunk ls trunk login.js main.html map.js movement.js style.css svn import svn://url/of/repo -m 'Initial commit' Adding trunk Adding trunk/login.js Adding trunk/movement.js Adding trunk/style.css Adding trunk/main.html Adding trunk/map.js Adding branches Adding tags Committed revision 1. $>

5 Checking Out a Repository Never edit a repository directly Check out a repository into a working directory Make edits in working directory Can use co instead of checkout cd development ls svn checkout svn://url/of/repo A demoapp/trunk A demoapp/trunk/login.js A demoapp/trunk/movement.js A demoapp/trunk/main.html A demoapp/trunk/style.css A demoapp/trunk/map.js A demoapp/branches A demoapp/tags Checked out revision 1. ls demoapp/trunk/ login.js main.html map.js movement.js style.css $>

6 Editing Your Working Directory You can make changes to any file Any changes to the file system must be made with svn commands:  svn add  svn rm  svn mkdir  svn mv  Etc… cd demoapp nano trunk/login.js svn status M trunk/login.js nano trunk/gameplay.js svn status ? trunk/gameplay.js M trunk/login.js svn add trunk/gameplay.js A trunk/gameplay.js svn status A trunk/gameplay.js M trunk/login.js svn rm trunk/movement.js D trunk/movement.js ls trunk gameplay.js login.js main.html map.js style.css $>

7 Updating Your Working Directory Before committing changes to the repo, always update Pulls in changes that anyone else might have made Automatically merges changes, even to the same file (sort of). svn update U trunk/map.js Updated to revision 2. svn status M trunk/login.js D trunk/movement.js A trunk/gameplay.js $>

8 svn update C trunk/login.js Updated to revision 3. ls trunk gameplay.js login.js login.js.mine login.js.r2 login.js.r3 map.js main.html style.css Resolving Conflicts Two people can make changes to the same part of the same file Subversion cannot automatically merge these Must be done by hand Edit the conflicted file to manually merge the changes Once complete, use svn resolved $>

9 cat trunk/login.js <<<<<<<.mine (function() { function login() { console.log('logging in'); } }()); ======= (function() { function login(){ window.alert('I AM NOW LOGGED IN!'); } }()); >>>>>>>.r3 nano trunk/login.js svn resolved trunk/login.js Resolved conflicted state of 'trunk/login.js' Resolving Conflicts Continued Two people can make changes to the same part of the same file Subversion cannot automatically merge these Must be done by hand Edit the conflicted file to manually merge the changes Once complete, use svn resolved $>

10 Commiting Your Changes Tell the repo about all the changes you’ve made to the working directory so far Use svn commit Always include a useful commit message  Use –m to include on the command line  Use –F to use the contents of a file svn status M trunk/login.js D trunk/movement.js A trunk/gameplay.js svn commit –m ‘Did awesome stuff’ Adding trunk/gameplay.js Sending trunk/login.js Deleting trunk/movement.js Transmitting file data.. Committed revision 4. svn status $>

11 Looking at History svn log shows a history of all commits svn log ----------------------------------------r4 | yule | 2013-05-23 14:08:42 -0300 (Thu, 23 May 2013) | 1 line Did awesome stuff ----------------------------------------r3 | yule | 2013-05-23 13:51:00 -0300 (Thu, 23 May 2013) | 1 line made the login code 100% more awesome ----------------------------------------r2 | yule | 2013-05-23 13:40:19 -0300 (Thu, 23 May 2013) | 1 line Fixed a bug in the mapping code... $>

12 Looking at History svn log shows a history of all commits svn diff shows the difference between revisions svn diff -r 3 Index: trunk/gameplay.js ========================================== Index: trunk/login.js ========================================== --- trunk/login.js (revision 3) +++ trunk/login.js (working copy) @@ -1,5 +1,5 @@ -(function() { - function login(){ - window.alert('I AM NOW LOGGED IN!'); +function() { + function login() { + console.log('logging in'); } }()); $>

13 Looking at History svn log shows a history of all commits svn diff shows the difference between revisions svn cat shows how a file looks at a certain revision svn cat trunk/login.js -r 3 (function() { function login(){ window.alert('I AM NOW LOGGED IN!'); } }()); $>

14 Looking at History svn log shows a history of all commits svn diff shows the difference between revisions svn cat shows how a file looks at a certain revision svn list gives the layout of the repo at a certain revision $> svn cat trunk/login.js -r 3 (function() { function login(){ window.alert('I AM NOW LOGGED IN!'); } }()); svn list trunk -r 3 login.js main.html map.js movement.js style.css $>

15 Important Points Never touch the.svn directory Always make sure to tell subversion about changes to the directory structure You can revert any changes using svn revert Many large projects use branches and tagging. You don’t need to.

16 This is way too hard! Use the svn help command Eclipse has the Subclipse pluginSubclipse plugin On Windows, you can use TortoiseSVN


Download ppt "Subversion. What is Subversion? A Version Control System A successor to CVS and SourceSafe Essentially gives you a tracked, shared file system."

Similar presentations


Ads by Google