| | 1 | [[PageOutline]] |
| | 2 | = Version Control with Subversion (svn) = |
| | 3 | == What is SVN? == |
| | 4 | * A free/open-source version control system. |
| | 5 | * Managing files and directories over time, placed into a central repository. |
| | 6 | * The repository remembers every changes ever made to the files and directories. |
| | 7 | * Accessible across networks, allowing to be used on different computers. |
| | 8 | * Runs on Many platforms. |
| | 9 | |
| | 10 | [http://subversion.apache.org Home Page] |
| | 11 | |
| | 12 | [[Image()]] |
| | 13 | |
| | 14 | == Good things... == |
| | 15 | * If you develop a software with some other people, it keeps track of who did what when and where changes. |
| | 16 | * even if you develop a software yourself... |
| | 17 | * When you made a stupid change and screwed up .... |
| | 18 | * Allows you to go back. |
| | 19 | * Revert to a previous revision of a file/directory. |
| | 20 | |
| | 21 | [[Image()]] |
| | 22 | |
| | 23 | == First things to do == |
| | 24 | * Create a repository on ''Cypress'' |
| | 25 | svnadmin create $HOME/repos |
| | 26 | This creates a repository under '$HOME/repos'. |
| | 27 | |
| | 28 | Note that $HOME is your home-directory on ''sphynx''. |
| | 29 | |
| | 30 | Once you did this, you don't have to do this again. Do not delete '$HOME/repos' !!! |
| | 31 | |
| | 32 | * Testing your repository |
| | 33 | On ''sphynx'', |
| | 34 | mkdir mywork |
| | 35 | cd mywork |
| | 36 | mkdir project1 |
| | 37 | echo "This is README.txt" > README.txt |
| | 38 | svn import file:///$HOME/repos/project1 -m"initial import" |
| | 39 | Now you have ''project1'' in your repository. |
| | 40 | |
| | 41 | Delete ''project1'' then checkout ''project1'' from the repository, |
| | 42 | cd .. |
| | 43 | rm -rf project1 |
| | 44 | svn co file:///$HOME/repos/project1 ./project1 |
| | 45 | |
| | 46 | === Working with SVN === |
| | 47 | * To download files in a repository, use ''''svn checkout'''' / ''''svn co'''' command. |
| | 48 | * If you made some changes to the files in your local machine and want to upload these to the repository, use ''''svn commit'''' command. |
| | 49 | * If you have files on your local machine and want to update these to the latest version in the repository, use ''''svn update'''' command. |
| | 50 | * If you want to add a file/direcotry, use ''''svn add'''' and commit. |
| | 51 | * If you want to delete a file/directory, use ''''svn delete'''' and commit. |
| | 52 | |
| | 53 | === What to Control === |
| | 54 | * Source Code |
| | 55 | * Documents |
| | 56 | * Variable data |
| | 57 | * Anything you want to share that isn't essentially static data. |
| | 58 | '''Do not upload.... Large sets of binary files; images, movie, music....''' |
| | 59 | |
| | 60 | === Accessing your Repository over Network === |
| | 61 | To access your Repository on ''sphynx' through ''ssh'' from other hosts, |
| | 62 | svn co svn+ssh://''USERNAME''@sphynx.ccs.tulane.edu/''HOME_DIRCTORY''/repos/project1 ./project1 |
| | 63 | |
| | 64 | You will be asked for typing your password on ''sphynx''. |
| | 65 | |
| | 66 | ''USERNAME'' and ''HOME_DIRCTORY'' are your login user name and home directory on ''sphynx''. |
| | 67 | |
| | 68 | To see the path of your home directory, on ''sphynx'' |
| | 69 | cat $HOME |
| | 70 | |
| | 71 | * Using svn-client software with GUI |
| | 72 | ** There are Windows Versions and Mac OS versions. |
| | 73 | ***[http://svn-ref.assembla.com/windows-svn-client-reviews.html Client Software Review] |
| | 74 | |
| | 75 | === Try using Your Repository === |
| | 76 | ==== Check out data ==== |
| | 77 | Somewhere on ''sphynx'', |
| | 78 | svn co file:///$HOME/repos/project1 ./project1 |
| | 79 | go into '''project1''' directory. |
| | 80 | cd project1 |
| | 81 | |
| | 82 | look at files |
| | 83 | ls |
| | 84 | |
| | 85 | ==== Edit README.txt ==== |
| | 86 | Edit '''README.txt''' to add your message. |
| | 87 | |
| | 88 | then commit it. |
| | 89 | svn commit -m"your message" |
| | 90 | |
| | 91 | |
| | 92 | ==== When you made a stupid change or delete a file by mistake ==== |
| | 93 | You can revert to a previous version. |
| | 94 | |
| | 95 | To look at the log |
| | 96 | svn log |
| | 97 | |
| | 98 | If you want to download version 1, |
| | 99 | svn -r 1 update |
| | 100 | |
| | 101 | When you delete '''README.txt by mistake, |
| | 102 | rm '''README.txt''' |
| | 103 | |
| | 104 | See the file you deleted does not exist. |
| | 105 | ls |
| | 106 | |
| | 107 | Download the missing file, |
| | 108 | svn update |
| | 109 | |
| | 110 | ==== Add files ==== |
| | 111 | Make a new file, then add it to svn by |
| | 112 | svn add NEW_FILE_YOU_MADE |
| | 113 | |
| | 114 | then |
| | 115 | svn commit -m"your message" |
| | 116 | |
| | 117 | ==== Check status ==== |
| | 118 | To check the status |
| | 119 | svn stat |
| | 120 | |
| | 121 | To see the difference between the repository and your working version |
| | 122 | svn diff |
| | 123 | |
| | 124 | ==== Upload ==== |
| | 125 | To upload your working version to the repository, |
| | 126 | svn commit -m"comment for current version" |
| | 127 | |
| | 128 | Look at the status and difference |
| | 129 | svn stat |
| | 130 | svn diff |
| | 131 | |
| | 132 | ==== Help ==== |
| | 133 | svn help |