Subversion Support in NetBeans IDE
NetBeans IDE now has a module available on the Update Center that provides
tight integration with versions 1.3 and 1.4 of the Subversion version control
system. This Subversion support is designed to focus on the tasks
you perform most often and especially to be integrated with the IDE's project
system. The workflow is very similar to that of the IDE's CVS integration.
This guide shows you the things you need to do get Subversion working with your
sources in the IDE and provides a quick overview of the most important features.
Getting Started
The new Subversion support is available on the Update Center for both for NetBeans IDE 5.5 and
for development builds of NetBeans IDE 6.0. It is not
available for NetBeans IDE 5.0. You can find all of these
versions of the IDE at http://www.netbeans.info/downloads/index.php.
Once you have installed the build, choose Tools > Update Center to download
and install the Subversion support from the IDE's Update Center. The Subversion
module is listed in the Features category of the Update Center.
Unlike with the IDE's CVS support, where the CVS commands are built into the IDE,
you need to install a Subversion client to get the IDE's Subversion support to work. The IDE's
Subversion support works with versions 1.3 and 1.4 of Subversion.
You can download Subversion as either sources or as a binary from
http://subversion.tigris.org/project_packages.html.
Note: Though the Subversion site does not guarantee the quality of the
binary downloads, you might find them easier to work with. For example,
the executable binary for Microsoft Windows systems sets up the environment
variable to make your system and the IDE recognize the Subversion installation.
Setting Up a Working Directory
This part is easy you don't have to do anything. The IDE automatically
scans your open projects and, if they contain .svn directories, shows
the Subversion status for the files and offers the full Subversion menu of commands.
Checking Out a New Project from Subversion
If you don't have the sources for your project checked out yet, you can do
so in the IDE:
- Choose Subversion > Checkout from the main menu.
- In the Repository URL field, enter the URL for the repository from which
you want to check out sources.
The IDE supports several URL protocols, such as
file, http, https, svn, and svn+ssh.
Depending on the protocol that you enter, other fields may also appear for you to
fill in.
- In the Folders to Checkout page, do the following things:
- In the Repository Folder(s) field, type or browse to the
folder you want to check out. In the Browse dialog box can use Ctrl-click to
select multiple folders.
- If necessary, use the Repository Revision field to specify a revision.
- In the Local Folder field, specify the folder to which you
would like to check out the files.
The IDE runs the Subversion checkout
command and prints the output to a tab in the Output window.
Once the files are checked out, the IDE does one of the following:
- If the module you checked out contains NetBeans project metadata,
the IDE offers to open the project.
- If the module does not contain NetBeans project metadata, the IDE
offers to create a new NetBeans project, which you can then associate
with the sources. In the New Project wizard, you should use one of the "With Existing Sources"
templates and then point to the sources.
Viewing File Status and Differences
The IDE gives you several ways of viewing status information about your files:
- Badges on your project, folder, and package nodes tell you about the status
of the files that are contained in the node.
- Individual file nodes are color-coded according to their status.
- The Diff command quickly diffs a single file or an entire package, folder,
or project.
- The Subversion window gives you a real-time list of all of the changed,
new, removed, and out-of-date files in any selected folder.
Badges and Color Coding
The IDE uses the badges and coloring in the following table to show status
of files, folders, packages, and projects.
 |
Blue badge on folder or package node |
Marks folders or packages that contain locally modified or new files.
For packages, this badge applies only to the package itself and
not its subpackages. For regular folders, the badge indicates presence
of local modification in that folder or any of its subfolders. |
 |
Red badge on folder or package node |
Marks folders or packages that contain conflicting files (local
conflicts). For packages, this badge applies only to the package
itself and not its subpackages. For regular folders, the badge indicates
presence of local modification in that folder or any of its subfolders. |
 |
Blue label |
Indicates that the file has been changed locally. |
 |
Red label |
Indicates that the file contains conflicts (sections marked with <<<<<
and >>>>>). For such files, you can use the Subversion > Resolve
Conflicts command to help you resolve those conflicts. |
 |
Gray label |
The file is ignored by Subversion and will not be part of any versioning commands
(such as Update and Commit). |
 |
Green label |
Indicates that the file has been locally added. |
 |
Strikethrough label |
The file is excluded from all commit operations. This label
appears in the Subversion window if you have specified that a file is not
to be included in commits. Such files are still affected by other
Subversion commands, such as Update. |
Tracking Changes in the Subversion window
The Subversion window presents a real-time view of the changes in selected folders. For
example, right-click any project that is in a Subversion working directory and choose
Subversion > Show Changes. The following window appears in the bottom of the IDE:

The Subversion window lists the following:
- All files that have changed locally. This includes all locally modified
files, locally added files, and locally deleted files.
- All files that have been changed, added, or removed in the repository.
- All files that have merge conflicts.
As you work with your files, the Subversion window is automatically updated
to show which files have changed. In the Subversion window, you can do any of the following:
- Use the buttons at the top of the window to filter the results to show
changes that you have made locally, changes that have been made remotely,
or all changes.
- Double-click any file to view a diff of the file in the Source Editor,
or click the
button to diff the entire selected project or folder.
- Right-click any file to access a contextual menu of commands.
- Use the buttons at the top of the window to update (
)
or commit (
)
all of the files listed in the window.
Generating Diffs
You can generate diffs in the IDE in the following ways:
- Right-click any node in the Projects window, Files window, or Favorites
window and choose Subversion > Diff. You can diff single files, folders, packages,
and projects.
- Click Diff All in the Subversion window to diff whatever projects or folders
the Subversion window is currently monitoring.
- Double-click a single file in the Subversion window.
The IDE displays your diffs in the Diff Viewer, which opens as a tab in the
Source Editor. The Diff Viewer shows the working copy
of the file in the left panel and the repository copy in the right panel.
In the new Subversion support, the viewer also shows the diffs for multiple files
in one tab. You can switch between files using the combo box. You can also
filter the diffs to show only changes you have made locally or changes made
in the repository.

Updating and Committing Files
Updating and committing files are the most common activities you perform with
Subversion. The IDE makes these actions as easy as possible. You can launch these actions
from the main IDE navigation windows (Projects, Files, and Favorites) or from
the Subversion window.
Updating Files
Updating files is easy:
- To update an entire project, the best way is to right-click the project
in the Projects window and choose Subversion > Show Changes. This gives you
a preview of all the files that will be changed before you update. Then
click the Update All button (
).
- To update an individual file, folder, or project, right-click its node
and choose Subversion > Update.
- To update all open projects, choose Subversion > Update All.
Committing Files
Like updating files, you can commit files from the Projects window (right-click
and choose Subversion > Commit), from the Subversion window (using the
button), or from the Subversion menu (commits all changes in all open projects).
When you run the Commit command, you see the following dialog:

The Commit dialog lists:
- All locally modified files. You can commit the files or exclude them from
the commit.
- All files new files that do not exist in the repository. You can choose
to add the file as text or as a binary file, or to exclude it from the commit.
See below for more on ignoring files.
- All files that have been deleted locally. You can remove the file from
the repository or exclude it from the commit.
- All files that you have renamed. If you include the such files in the
commit, Subversion renames the file in the repository.
Ignoring Files
The IDE automatically suggests adding all local files to the repository when
you run the commit command on a folder. It is therefore important to tell
the IDE which files to ignore. You can ignore files in two ways:
- In the Projects window, Files window, or Favorites window, right-click
a folder or file and choose Subversion > Ignore. When you choose this command,
the file is not affected by Subversion commands.
- In the Commit dialog box, change the Commit Action to Exclude from Commit.
Whenever you run the Commit command on the folder or project, the ignored
file will be listed in the dialog box but will be excluded from the commit.
When you are ready to commit the file, change the Commit Action back to
Commit.
Projects and Subversion
The IDE's Subversion support makes it easy to share your project metadata so
that you can share not only your sources, but your IDE project settings as well. The
IDE automatically excludes your build, dist, and nbproject/private
folders from check-in.
Updating Project Settings
All of your project settings are stored in your build.xml file and
the files in your nbproject folder. When you run the Update or
Commit commands on a project node in the IDE, both your sources and your project
settings are updated or committed. If you just want to run Subversion commands on
project settings, go to the Files window, right-click build.xml and
nbproject, and choose Subversion > Update or Subversion > Show Changes. Likewise,
if you just want to perform Subversion commands on your sources, it is best to run
the Show Changes command on the source folders in the Files window or source
package nodes in the Projects window, then update or commit from the Subversion
window.
Putting a Project into Subversion
If you have a local project, you can quickly put it into Subversion:
- Clean your project so that the IDE does not put your build output folders
into Subversion.
- Right-click the project node in the Projects window and choose Subversion >
Import Project into Repository.
- Specify a repository, enter a comment, and click OK. The IDE imports your
sources and project metadata into Subversion and then checks them out again as
a local Subversion folder.