Changes between Version 2 and Version 3 of Cross/SVNGuidelines

Show
Ignore:
Timestamp:
09/14/09 09:06:48 (15 years ago)
Author:
bhilburn
Comment:

--

Legend:

Unmodified
Added
Removed
Modified
  • Cross/SVNGuidelines

    v2 v3  
    3030 
    3131Before you can commit changes to a file to the repository, you must first tell the repository that it should monitor the file. To do this, use the ‘add’ command: 
    32  
     32{{{ 
    3333$ svn add <file> 
    34  
     34}}} 
    3535Note that a file only needs to be ‘added’ to the repo once! 
    3636 
     
    3939 
    4040Now that the SCM is monitoring the file, you can commit the changes you have made to the file by using the ‘commit’ command: 
    41  
    42     $ svn ci <file> -m “Initial check-in.” 
    43  
     41{{{ 
     42$ svn ci <file> -m “Initial check-in.” 
     43}}} 
    4444Note that each time you commit changes to a file, you should submit a comment explaining what you changed. This is done by using the ‘-m’ option, and putting the comment in quotes. 
    4545 
     
    5151 
    5252Subversion provides a way to add files to the repo and commit them recursively in one fell-swoop. This is done using the svn ‘import’ command. 
    53  
    54     $ svn import <file/directory> <URL> 
    55  
     53{{{ 
     54$ svn import <file/directory> <URL> 
     55}}} 
    5656The ‘import’ command will recursively add and commit an entire directory, or a single file, to the repo at the provided URL. Furthermore, if the directory structure passed into the URL doesn’t exist, ‘import’ will create the folders necessary to create the path. 
    5757 
     
    6161 
    6262Let’s say that there is a file in the repository that you want to edit. First, you need to ‘check-out’ the file to get the most recent copy of it on your computer. 
    63  
    64     $ svn co <https://path/to/repo/and/file> 
    65  
     63{{{ 
     64$ svn co <https://path/to/repo/and/file> 
     65}}} 
    6666This will pull the file from the repo into the current directory on your computer. Again, note that if the passed path actually points to a directory rather than a single file, the whole directory will be downloaded to your machine. 
    6767 
     
    7171 
    7272‘Updating’ a file simply means pulling the most recent version of the file from the repo. This should be done on a regular basis to ensure that you are always working on the most up-to-date version of the file. Updating is quite simple: 
    73  
    74     $ svn update <file> 
    75  
     73{{{ 
     74$ svn update <file> 
     75}}} 
    7676If no file argument is passed to the command, then it will update every file in the current directory. This is the most common usage of the command. 
    7777 
    7878It is also possible to ‘update’ a file to a specific revision. This is done using the ‘-r’ option: 
    79  
    80     $ svn update -r<revision> <file> 
    81  
     79{{{ 
     80$ svn update -r<revision> <file> 
     81}}} 
    8282If the passed revision number is lower than your current revision, then you are effectively downgrading that file. 
    8383 
     
    8585 
    8686There is a subversion command to do exactly what the standard ‘mv’ UNIX command does – i.e. move a file from one name/location to another: 
    87  
    88     $ svn mv <file1> <file2> 
    89  
     87{{{ 
     88$ svn mv <file1> <file2> 
     89}}} 
    9090Just like the traditional UNIX command, svn ‘mv’ can be used to rename a file or change it’s directory location. Any changes made will need to be committed, using the process discussed previously. 
    9191 
     
    9393 
    9494So you’ve been editing a bunch of files, and you’ve forgotten which files you’ve edited and exactly what changes you have made (Note: If you are in this position, then you have probably violated a basic principle of using a SCM, which we will discuss later). In order to see what files you have changed, you can use the ‘status’ command: 
    95  
    96     $ svn status 
    97  
     95{{{ 
     96$ svn status 
     97}}} 
    9898This command will list every file in the current directory that has been modified in some way. These files are listed with keys, indicating how they have been changed. Now, let’s say you want to look at the specific changes made in one file. This can be done with the ‘diff’ command: 
    99  
    100     $ svn diff <file> 
    101  
     99{{{ 
     100$ svn diff <file> 
     101}}} 
    102102This command will list all of the differences between your local copy of the file, and the version currently stored in the repo. 
    103103 
     
    105105 
    106106Argh! You accidently just wrote a bunch of changes to a file that broke everything! Time to revert! 
    107  
    108     $ svn revert <file> 
    109  
     107{{{ 
     108$ svn revert <file> 
     109}}} 
    110110Reverting a file will throw away all of the changes you made to the file, and pull a pristine copy of the file from the repository. 
    111111 
     
    119119 
    120120Creating a ‘branch’ is really very easy. You merely copy the current trunk development line into another directory: 
    121  
    122     $ svn copy https://path/to/repo/trunk https://path/to/repo/branch 
    123  
     121{{{ 
     122$ svn copy https://path/to/repo/trunk https://path/to/repo/branch 
     123}}} 
    124124All of your experimental work should be committed to your branch to prevent breaking the trunk code-base for everyone else. 
    125125 
     
    129129 
    130130Let’s say that when you originally branched, you were at revision 100. Your branch line at the end of development was at revision 150. To commit the changes occurring in your branch from revisions 101 to 150, from the trunk directory, you would do: 
    131  
    132     $ svn merge -r101:150 https://path/to/repo/branch 
    133  
     131{{{ 
     132$ svn merge -r101:150 https://path/to/repo/branch 
     133}}} 
    134134This tells the VCS to grab all of the changes made to the passed branch directory from revisions 101 to 150, and apply them to the current directory, which should be trunk if you run it from the trunk directory. 
    135135 
     
    139139 
    140140Tags provide a way of storing what the development line looked like at a certain point in time. They should be treated as read-only directories, created solely for check-outs. They are primarily used for indicating a release. To create a tag, merely copy the current development line into another directory: 
    141  
    142     $ svn copy https://path/to/repo/trunk https://path/to/repo/tag 
    143  
     141{{{ 
     142$ svn copy https://path/to/repo/trunk https://path/to/repo/tag 
     143}}} 
    144144Note that calling something a tag does not make it read-only in the repo. It is up to the developers to honor something called a ‘tag’, and not commit changes to it. 
    145145