Source Control
Source Control
Source Insight is designed to work well in team programming situations. As team programmers contribute to the code base, Source Insight automatically recognizes their contributions and updates its symbolic information. Moreover, as large amounts of new code are added to a project, or moved from module to module, you will appreciate Source Insight's ability to keep track of everything for you.
Using Source Control in Source Insight
Source Insight has a few predefined Custom Commands built-in to handle common source control operations. You can invoke them by using the source control toolbar. For example, there are "Check Out" and
"Check In" commands. The general meaning of the source control commands is summarized in the next section.
Source Insight works best if each team member has their own local copies (or code repositories) of the project source files on their own local machine. This provides the best performance and reliability.
Source Control Commands
Source Insight has a few predefined Custom Commands built-in to handle common source control operations. Use the Tools > Custom Commands dialog box to edit the commands. You can easily change them to support different source control, or version control systems.
The source control commands appear in the table below. Their exact meanings are really based on how you
choose to set them up in the Custom Commands dialog box. See “Custom Commands” on page 177. Source
Insight defines the following command semantics.
Command Name
Check Out
Check In
Undo Check Out
Sync to Source Control
Project
Sync File to Source Control Project
Table 3.2: Source Control Commands
Action
Checks the current file out of the Source Control project, so that you can edit it.
Checks the current file into the Source Control project. You should use Check In after you are finished editing a file, and want to put it back into the main Source Control project for other team members to access.
Reverses the action of a Check Out. This does not check the file back in.
Updates all the files in your local project so they are current with respect to the Source Control project.
Updates the current file so it is current with respect to the Source Control project.
66 Source Insight 4 User Guide
Source Control
Source Control Toolbar
The Source Control toolbar contains buttons for each of the source control commands.
Check In Sync To Source Control
Project
Check Out Undo
Check Out
Sync File To Source
Control Project
Figure 3.3 The Source Control toolbar
Using IBM® Rational ClearCase ® Commands
IBM® ClearCase® is a version control system that is used by software developers. The following table lists the
Source Control commands in Source Insight, and useful settings for using ClearCase.
Custom Command
Check Out
Check In
Table 3.3: ClearCase Source Control Commands
Run String
cleartool checkout -unr -nc %f cleartool checkin -nc %f cleartool uncheckout %f cleartool update
Description
check out current file unreserved
(non-locking), no comment check in current file without comment undo check out of current file update the view
Undo Check Out
Sync to Source Control Project
Sync File to Source
Control Project cleartool update %f update the current file in the view
Edit each of the above Custom Commands, and set the "Run" string from the above table.
Note:
A shortcut to edit a Custom Command is to hold down the Ctrl key while clicking on one of the source control icons in the toolbar. For example, Ctrl+click on the "Check Out" button. The Custom Command dialog will appear open to the "Check Out" command.
The cleartool utility must be on your PATH. If not, replace the instances of cleartool
above with the full path to the cleartool.exe command on your machine.
The
%f
parameter in the "Run" string of a custom command will be replaced with the full path of the current file.
You may want to alter some of the options specified above. You can also add more commands for additional operations. Please refer to ClearCase documentation.
Using Git Commands
Git is a free and open source distributed version control system The following table lists the predefined
Source Control commands in Source Insight, and useful settings for using Git.
Source Insight 4 User Guide 67
Source Control
Git has many fine-grained commands and concepts that go beyond the relatively simple source control concept used in Source Insight. The following table is one version that you may find useful. You can always add more custom commands in Source Insight for addition Git commands.
Custom Command
Check Out
Check In
Undo Check Out
Sync to Source Control Project
Sync File to Source
Control Project
Run String
n/a
Table 3.4: Git Source Control Commands
git commit %r -m "" git checkout -- %r git pull origin git fetch origin;git checkout FETCH_HEAD
-- %r
Description
With Git, there really isn’t a need to check a file out first. Simply modify your copy of the file as you want.
Use the "Check In" command to commit your change when you are done.
Commit the current file to your local repository without comment.
This command actually undoes the modifications to the file since you last committed the file.
Pulls new changes from the remote repository and updates all files in the current branch.
By default, "origin" is the name of the repository you first cloned from. If you have a specific repository you want to pull from, you should replace "origin" with the name of the repository.
Git pull will perform merges as needed if you have both local changes, and changes in the remote version of a file since you last pulled the file.
Effectively pulls changes for a single file from the remote repository.
Edit each of the above Custom Commands, and set the "Run" string from the above table.
Note:
A shortcut to edit a Custom Command is to hold down the Ctrl key while clicking on one of the source control icons in the toolbar. For example, Ctrl+click on the "Check Out" button. The Custom Command dialog will appear open to the "Check Out" command.
The
%r
parameter in the "Run" string of a custom command will be replaced with the path of the current file relative to the project’s root source directory.
The git.exe
and associated executables must be on your PATH.
Additional Git Information
Before you can use the commands above on a given file, the file must be part of the Git repository. To add a new file to your local repository, use the "add" command: git add <file>
And follow it by: git commit -m "here is my comment"
By default, "origin" is the name of the repository you first cloned from. If you have a specific repository you want to pull from, you should replace "origin" with the name of the repository. In addition, if you need to pull from a specific branch of the remote, you should specify origin <branch-name>
in the commands.
68 Source Insight 4 User Guide
Source Control
You will need to install Git and initialize your local repository with the git init
command before using any of these commands. Furthermore, you can configure Git so that the Git commands automatically work with your remote repository.
For information on Git, please refer to https://git-scm.com/
Source Insight 4 User Guide 69