[[PageOutline]] = Version Control with Subversion (svn) = == What is SVN? == * A free/open-source version control system. * Managing files and directories over time, placed into a central repository. * The repository remembers every changes ever made to the files and directories. * Accessible across networks, allowing to be used on different computers. * Runs on Many platforms. [http://subversion.apache.org Home Page] [[Image(SVN_model.png)]] == Good things... == * If you develop a software with some other people, it keeps track of who did what when and where changes. * even if you develop a software yourself... * When you made a stupid change and screwed up .... * Allows you to go back. * Revert to a previous revision of a file/directory. [[Image(SVN_revision.png)]] == First things to do == * Create a repository in your home directory on ''Cypress'' {{{#!bash [fuji@cypress2 ~]$ svnadmin create $HOME/repos }}} This creates a repository under '$HOME/repos'. Note that $HOME is your home-directory on ''Cypress''. Once you did this, you don't have to do this again. Do not delete '$HOME/repos' !!! * Testing your repository On ''Cypress'', {{{#!bash mkdir mywork cd mywork mkdir project1 echo "This is README.txt" > README.txt svn import file:///$HOME/repos/project1 -m"initial import" }}} Now you have ''project1'' in your repository. Delete ''project1'' then checkout ''project1'' from the repository, {{{#!bash cd .. rm -rf project1 svn co file:///$HOME/repos/project1 ./project1 }}} === Working with SVN === * To download files in a repository, use ''''svn checkout'''' / ''''svn co'''' command. * If you made some changes to the files in your local machine and want to upload these to the repository, use ''''svn commit'''' command. * If you have files on your local machine and want to update these to the latest version in the repository, use ''''svn update'''' command. * If you want to add a file/direcotry, use ''''svn add'''' and commit. * If you want to delete a file/directory, use ''''svn delete'''' and commit. === What to Control === * Source Code * Documents * Variable data * Anything you want to share that isn't essentially static data. '''Do not upload.... Large sets of binary files; images, movie, music....''' === Accessing your Repository over Network === To access your Repository on ''Cypress' through ''ssh'' from other hosts, {{{#!bash svn co svn+ssh://''USERNAME''@cypress.tulane.edu/''HOME_DIRCTORY''/repos/project1 ./project1 }}} You will be asked for typing your password on ''Cypress''. ''USERNAME'' and ''HOME_DIRCTORY'' are your login user name and home directory on ''Cypress''. To see the path of your home directory, on ''Cypress'' {{{#!bash cat $HOME }}} * Using svn-client software with GUI * There are Windows Versions and Mac OS versions. *[http://svn-ref.assembla.com/windows-svn-client-reviews.html Client Software Review] === Try using Your Repository === ==== Check out data ==== Somewhere on ''Cypress'', {{{#!bash svn co file:///$HOME/repos/project1 ./project1 }}} go into '''project1''' directory. {{{#!bash cd project1 }}} look at files {{{#!bash ls }}} ==== Edit README.txt ==== Edit '''README.txt''' to add your message. then commit it. {{{#!bash svn commit -m"your message" }}} ==== When you made a stupid change or delete a file by mistake ==== You can revert to a previous version. To look at the log {{{#!bash svn log }}} If you want to download version 1, {{{#!bash svn -r 1 update }}} When you delete '''README.txt by mistake, {{{#!bash rm '''README.txt''' }}} See the file you deleted does not exist. {{{#!bash ls }}} Download the missing file, {{{#!bash svn update }}} ==== Add files ==== Make a new file, then add it to svn by svn add NEW_FILE_YOU_MADE then svn commit -m"your message" ==== Check status ==== To check the status {{{#!bash svn stat }}} To see the difference between the repository and your working version svn diff ==== Upload ==== To upload your working version to the repository, {{{#!bash svn commit -m"comment for current version" }}} Look at the status and difference {{{#!bash svn stat svn diff }}} ==== Help ==== {{{#!bash svn help }}}