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