Product SiteDocumentation Site

4.11. Commit Your Changes

Finally! Your edits are finished, you've merged all changes from the server, and you're ready to commit your changes to the repository.
The svn commit command sends all of your changes to the repository. When you commit a change, you need to supply a log message, describing your change. Your log message is attached to the new revision you create. If your log message is brief, you may wish to supply it on the command line using the --message (or -m) option:
$ svn commit -m "Corrected number of cheese slices."
Sending        sandwich.txt
Transmitting file data .
Committed revision 3.
However, if you've been composing your log message in some other text file as you work, you may want to tell Subversion to get the message from that file by passing its filename as the value of the --file (-F) option:
$ svn commit -F logmsg
Sending        sandwich.txt
Transmitting file data .
Committed revision 4.
If you fail to specify either the --message (-m) or --file (-f) option, Subversion will automatically launch for favorite editor (your default editor) for composing a log message.
If you're in your editor writing a commit message and decide that you want to cancel your commit, you can just quit your editor without saving changes. If you've already saved your commit message, simply delete sll the text, save again, and then abort:
$ svn commit

Log message unchanged or not specified
(a)bort, (c)ontinue, (e)dit:
a
$
The repository doesn't know or care whether your changes make any sense as a whole; it checks only to make sure nobody else has changed any of the same files that you did when you weren't looking. If somebody has done that, the entire commit will fail with a message informing you that one or more of your files are out of date:
$ svn commit -m "Add another rule"
Sending        rules.txt
svn: E155011: Commit failed (details follow):
svn: E155011: File '/home/sally/svn-work/sandwich.txt' is out of date
...
(The exact wording of this error message depends on the network protocol and server you're using, but the idea is the same in all cases.)
At this point, you need to run svn update, deal with any merges or conflicts that result, and attempt your commit again.
That covers the basic work cycle for using Subversion. There are many other features in Subversion that you can use to manage your repository and working copy, but most of your day-to-day use of Subversion involves only the commands that we've discussed in this chapter.

4.11.1. Exercise - Commit Changes to the Repository

Commit your local changes to the CS390X repository.
Reflect on the process. Did your commit work the first time? If not, why not? Were there conflicts? What did you do to resolve them?