1 / 23

An Crash Course in Version Control with Subversion

An Crash Course in Version Control with Subversion. Checking Out. Repositories can be local or remote. Remote repositories accessed via WebDAV are ideal for collaboration

darena
Download Presentation

An Crash Course in Version Control with Subversion

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. An Crash Course inVersion Control with Subversion

  2. Checking Out • Repositories can be local or remote. Remote repositories accessed via WebDAV are ideal for collaboration • $ svn checkout \https://svn.crew/svn/general/A READMEA benderA bender/LICENSEA bender/READMEA bender/README.crew...

  3. Checking Out, cont. • Check out just subdirectories:$ svn co https://svn.crew/svn/general/rtbot/libA libA lib/bot_msg.pl... • Check out the repository at a specific revision:$ svn checkout -r 271 https://... • Keeping your local copy up-to-date:$ svn update

  4. What I Got • $ lsREADME bender/fortune/ handbook/hostpool/ ircd/jabber/ ldap/...

  5. Willy-nilly! • No locks, so go nuts!$ rm -rf bender$ mkdir blorg$ vim README$ /dev/random | head \> ldap/important_info

  6. Wha’ happened? • $ svn statusM README! bender? blorg? ldap/important_info

  7. Removing • $ svn rm benderD bender • $ svn status...D bender... • bender and subdirectories won’t be deleted until commit

  8. Oops, I want that! • Revert a file or directory to the state when it was checked out • $ svn revert -R benderReverted ‘rtbot’Reverted ‘rtbot/README’Reverted ‘rtbot/lib’...

  9. Adding Things • $ vim file.txt$ svn add file.txt • $ mkdir testdir$ svn add testdir • If you already have stuff in the directory, Subversion will do add the items recursively • If you have un-added stuff in the already-added directory, Subversion will simply tell you the directory is already under version control • $ svn mkdir testdir • $ svn mkdir https://.../testdir

  10. Moving Things • $ mv file.txt file2.txt$ svn status! file.txt? file2.txt • $ svn mv file.txt file2.txt$ svn statusD file.txtA + file2.txt • CVS has no mv command — you have to hack the repository to save history

  11. Copying Things • $ cp file.txt file2.txt$ svn status? file.txt • $ svn cp file.txt file2.txtA file2.txt$ svn statusA + file2.txt • “cheap copy”

  12. Cheap, you say? • Not hogwash! Copying simply creates a new stub in the repository, rather, a pointer to another file in the repository at a certain revision • Easily create tags that mark an entire revision of the repository, or part thereof • $ svn cp project/trunk project/tags/1.2 • $ svn cp https://../trunk https://../1.2

  13. Making a Difference • $ svn diff file.txt... • $ svn diff -r 123:124 file.txt... • Subversion also does binary diffs

  14. Commitment • $ svn commit(in $EDITOR:)I did stuff--This line, and those below, will be ignored--D file.txtA + file2.txt • $ svn ci -m ‘I did stuff’

  15. Simple Merging • I edit the same file as Muncus. He checks in before I do. I try to commit my changes:$ svn ci -m ‘added info’Sending file.txtsvn: Commit failed (details follow):svn: Out of date: ‘file.txt’ ...$ svn upG file.txt$ svn diff file.txt...

  16. Not-So-Simple Conflicts • Muncus and I edit the same lines of the same file.$ svn upC file.txt$ lsfile.txt file.txt.minefile.txt.r2 file.txt.r3

  17. Conflict Files • file.txt.mine — my changes, formerly just file.txt • file.txt.r2 — the previous revision’s copy, before Muncus’ change • file.txt.r3 — the latest revision’s copy, after Muncus’ change • file.txt — line-by-line conflict listings

  18. Line-by-Line Conflict Files • This line didn’t change.<<<<<<<<<<<<<< .mineDon’t touch this line.==============muncus 0wnz j00!!!11!>>>>>>>>>>>>>> .r3This line didn’t change, either.

  19. Resolving Conflicts • Fix the file • Fix conflicts by hand using editor & conflict markers • Use one of the revision files • Revert the file • Mark the file as OK • $ svn resolved file.txt • Shake hands

  20. Handy Commands • $ svn help • $ svn help command • $ svn cleanup • $ svn cat -r 277 file.txt • $ svn blame file.txt • $ svn export https://.../

  21. Properties • $ svn propset svn:keywords “Id” file.txt$ vim file.txtThis is version $Id$$ svn ci -m ‘added ID thingey’$ cat file.txtThis is version $Id: file.txt 277 ... ian $

  22. Ignoring Ignorables • Sometimes the output of svn status gets annoying if you’re editor makes swap files, or you don’t care about object files... • $ svn propedit svn:ignore .*.class.*.swp • Doesn’t descend into subdirs

  23. Where to Go From Here • Roll your own repository:$ svnadmin create myrepos$ svn co file://$HOME/myrepos stuff • Read the Subversion Book • http://svnbook.red-bean.com/

More Related