SVN for macOS

Notes

Checking out your svn repo

  1. install homebrew via https://brew.sh/
  2. install svn with the command
    brew install svn
  3. add brew to path with the command
    (echo; echo 'eval "$(/opt/homebrew/bin/brew shellenv)"') >> ~/.zprofile eval "$(/opt/homebrew/bin/brew shellenv)"
  4. change the current working directory to the desktop with the command
    cd desktop
  5. check out your svn repo with the command (note the sample URL is for CSIA, please update for your course)
    svn checkout --username USERNAME https://svn.cs.kent.edu/courses/cs13011/svn/USERNAME/
    A folder should now be on your desktop called "USERNAME"
You now have a copy of your svn repo locally,

Adding a directory/folder/project/file to svn

  1. To locate the folder for your project in Xcode, right click on the project name on the left hand side of the screen (you want the very top one if the name appears multiple times)
  2. select "show in finder"
  3. A finder window should appear, in it right click on the project name (the folder) and click copy
  4. On your desktop open the folder "USERNAME", right click and paste
  5. Open terminal and change the current working directory to your local copy of the svn repo with the command
    cd desktop/USERNAME
  6. add your project with the following command (notice once you type the first few characters you can auto complete by pressing tab)
    svn add PROJECT_NAME
  7. commit your changes with the command
    svn commit -m ''
    (include the empty quote at the end; they are two single quotes)
  8. verify on the web that you can see your source code (not just the folder)

Removing a directory/folder/project/file from svn

  1. Open terminal and change the current working directory to your local copy of the svn repo with the command
    cd desktop/USERNAME
  2. remove your project with the following command (notice once you type the first few characters you can auto complete by pressing tab)
    svn rm PROJECT_NAME
  3. commit your changes with the command
    svn commit -m ''
    (include the empty quote at the end; they are two single quotes)
  4. verify on the change on the web

Updating a directory/folder/project/file from svn

it is recommended for simplicity that you simply remove your old project and then add it again, however you may find it faster to do the following
  1. Locate the folder for your project in Xcode this can be done by right clicking on the project name on the left hand side of the screen (you want the very top one if the name appears multiple times)
  2. select "show in finder"
  3. A finder window should appear, in it right click on the project name (the folder) and click copy
  4. On your desktop open the folder "USERNAME", right click and paste (if asked if you would like to overwrite/replace select yes)
  5. Open terminal and change the current working directory to your local copy of the svn repo with the command
    cd desktop/USERNAME
  6. commit your changes with the command
    svn commit -m ''
    (include the empty quote at the end; they are two single quotes)
  7. This will not add new files to the project, it will only update the ones that have already been added. New files must be added with the command svn add

Troubleshooting
Other Essential Subversion Commands
You may find the video for CSII helpful, you can find it here or this youtube tutorial here

svn checkout http://www.foo.edu/svn/oop/username
svn co http://www.foo.edu/svn/oop/username
Checks out a working copy from the repository. Normally only do this once or when something is messed up and you need a fresh copy from the server.

svn update
Brings your working copy up-to-date with the server repository. Any changes made in the repository are put into your working copy. Always do this before you start working on a file (or repo).

svn add filename
Puts the file filename under control of the versioning system. Do this once when you create a new file or folder.

svn commit -m "Added new method."
svn ci -m "Added new method."
Commits the changes that you have made to the working copy to the server repository with a comment. Do this everytime you stop working on a file.

svn status
Gives the status of all files in the current versioned directory/folder. Tells you if files are under version control (been added). '?' - file is not under version control. You may have forgotten to do an svn add. Object files (e.g., main.o) should not be under version control and will have a ?. 'M' the file is modified. You will need to do a commit.

svn delete filename
Deletes the file filename. Only occurs in the working copy, i.e., must be committed to show up in the repository.

svn mv oldfilename newfilename
Changes the name of a file from oldfilename to oldfilename. Only occurs in the working copy, i.e., must be committed to show up in the repository.

svn mkdir directory_filename
Creates a new directory with the name directory_filename. Only occurs in the working copy, i.e., must be committed to show up in the repository.

svn mv old_directory new_directory
Changes the name of the directory with the name old_directory to the new name old_directory. Make sure to commit any work that you have and perform an update first to avoid any problems. Only occurs in the working copy, i.e., must be committed to show up in the repository.

svn log filename
Presents information about the various versions of filename. Can be used to find the version number that corresponds to a version that you may want (based on the annotation given when committed).

svn update filename -r####
If you want to move back to a previous version use the update with the -r option. Get the version number from svn log filename and put it in the ####.