4.6. Make Changes to Your Working Copy
Now you can get to work and make changes in your working copy. It's usually most convenient to decide on a discrete change (or set of changes) to make, such as writing a new feature, fixing a bug, etc. The Subversion commands that you use here are svn add
, svn delete
, svn copy
, svn move
, and svn mkdir
. However, if you are merely editing files that are already in Subversion, you may not need to use any of these commands until you commit.
There are two kinds of changes you can make to your working copy: file changes and tree changes. You don't need to tell Subversion that you intend to change a file; just make your changes using your text editor, word processor, graphics program, or whatever tool you would normally use. Subversion automatically detects which files have been changed, and in addition handles binary files just as easily as it handles text files -- and just as efficiently too. For tree changes, you can ask Subversion to mark files and directories for scheduled removal, addition, copying, or moving. These changes may take place immediately in your working copy, but no additions or removals happen in the repository until you commit them.
Here is an overview of the five Subversion subcommands that you'll use most often to make tree changes.
svn add foo
Schedule file, directory, or symbolic link foo
to be added to the repository. When you next commit, foo
becomes a child of its parent directory. Note that if foo
is a directory, everything underneath foo
is scheduled for addition. If you only want to add foo
itself, pass the --non-recursive
(-N
) option.
svn delete foo
Schedule file, directory, or symbolic link foo
to be deleted from the repository. If foo
is a file or link, it is immediately deleted from your working copy. If foo
is a directory, it is not deleted, but Subversion schedules it for deletion. When you commit your changes, foo
is entirely removed from your working copy and the repository.
svn copy foo bar
Create a new item bar
as a duplicate of foo
and automatically schedule bar
for addition. When bar
is added to the repository on the next commit, its copy history is recorded (as having originally come from foo
). The svn copy
command does not create intermediate directories.
svn move foo bar
This command is exactly the same as running svn copy foo bar; svn delete foo
. That is, bar
is scheduled for addition as a copy of foo
, and foo
is scheduled for removal. The svn move
command does not create intermediate directories.
svn mkdir blort
This command is exactly the same as running mkdir blort; svn add blort
. That is, a new directory named blort
is created and scheduled for addition.
4.6.1. Exercise - Create a Biography File and Add It to the Local Repository
Using other biography files as examples, create a biography file of yourself in the bio/
directory and add it to your local repository. Also add a link to that file in the index.html
file in the root directory.