Linking a Git commit to a work item from a Git command line

You can link a Git commit or Gerrit change from the Git command line to a Rational Team Concert™ work item by annotating the Git commit message with an identifier for the work item to which you are linking.

Before you begin

Git projects must be registered with the adapter and associated with one or more Rational Team Concert project areas. You can create links from any Git client. All configuration is done when the adapter is installed on the server. No further configuration is required to your local environment to use the adapter.

About this task

The Git adapter automatically creates a link between a Git commit (or Gerrit change) and a Rational Team Concert work item when you push changes to the shared repository, if the commit message contains a reference to a Rational Team Concert work item. The message must include the Git adapter change request tag, the number of the Rational Team Concert work item you are linking to, and, optionally, the name of the Rational Team Concert project area containing the specified work item. If no project name or abbreviation is specified, the default Rational Team Concert project associated with the Git adapter is used. A single commit can link to multiple Rational Team Concert work items and multiple commits can link to a work item.

Change request tags are specified by your system administrator as part of configuring the receive hook. The default is bug.

Procedure

  1. Complete you Git or Gerrit work as your normally would.
  2. When you commit work to your local repository, annotate the commit message to include information about the Rational Team Concert work item to link to.
    • If the work item is in the default Rational Team Concert project area use either of these forms. The default project is set by your system administrator:
      • <change_request_ tag> <work_item _number>
      • <change_request_tag>: <work_item_number>
    • If the work item is in a non-default Rational Team Concert project area, use one of the following forms. The project must be registered with the adapter.
      • <change_request_tag>(full_project_name) <work_item_number>
      • <change_request_ tag>: (full_project_name) <work_item_number>
      • <change_request_tag>(project_alias) <work_item_number>
      • <change_request tag>: (project_alias) <work_item_number>
  3. Push the commit to a registered common repository to create the link.

Example

  • In the following commit message, bug(JKE) 12 on line 4 says that the commit is associated with work item 12 in the Rational Team Concert JKE project and uses the change request tag bug. The link is created when the commit is pushed to the registered repository.
    1 Fixed the instructions in the shared readme file 
    2 
    3 Updated the instructions in the shared readme file 
    4 fix bug(JKE) 12 
  • The following command creates a link to work item 113 in the default Rational Team Concert project. The link is created when the commit is pushed to the registered repository.
    > git commit -m 'Here is my fix for bug 113'

Feedback