How to Use Git with Codebeamer
The following sections explain how to set up and use a Managed Git Repository in
Codebeamer. The
Codebeamer terminology distinguishes between managed and external repositories. For more information, see
Using Managed Subversion, Git & Mercurial Repositories.
Setting Git User Name - Author (Step 1)
| The username and passwords must match those registered withCodebeamer. This allows the Codebeamer server to correctly associate the user's local commits user when pushing them to the server. Codebeamer tries to resolve the identity of the change, but if this fails the push will be rejected (even if the authentication was correct) |
Configure your Git client to set author information on commits. The author must match the Codebeamer username. Enter the following commands in the terminal (global git configuration):
git config --global user.name my.codebeamer.username
git config --global user.email my@registered.codebeamer.address.com
Cloning Repositories, Committing and Pushing Changes (Step 2)
For a local copy of the source code, clone the repository:
git clone http://account-
name@codebeamer.server.name.or.ip:port/cb/git/your.repo.name
You can clone the repository using SSH :
git clone ssh://codebeamer@codebeamer.server.name.or.ip/git/your.repo.name
You can commit your changes to the repository.
cd your.local.repository.dir
echo Hello > new.file.name
git add new.file.name
git commit -m Commit message, added new file
This will commit changes locally to your repository. To send (push) your changes to remote (upstream) repository:
git push origin master
| A push operation can send more than one commits to Codebeamer. Make your changes and repeat the steps above without the push. When you want to share your work, execute a git pull to get the latest revisions and update (or merge) your local clone, and then execute git push. That will send all the changes at once. |
Encoding related information
The files that you commit into git, and push to Codebeamer must be encoded using UTF-8. Otherwise the system displays the diffs and file contents incorrectly.
Associating Issues with Commits (Step 3)
To associate an issue with a commit, first create an issue within a Codebeamer tracker. Remember or jot down the id-number of the generated issue, and start working on implementing/fixing source code in connection with it. When you are finished, open a terminal window and enter the following commands (replace 1234 with the ID of the issue you want to associate your commit with):
cd your.local.repository.dir
git commit -a -m #1234 Fixing an NPE
Use the issue ID you've created: this will commit changes locally to your repository. Now send your changes to Codebeamer:
git push origin master
Login to Codebeamer and:
1. Select your Project from context menu.
2. Click on the SCM Repositories tool menu.
3. Select the (upstream) repository.
You can now see your commit(s) on top of the history, and the issue associated with your change. You can check the back association by clicking on this link, and see your change information on SCM Commits tab on the bottom.
For more information on associating issues with commits, see
Tracing Source Code Changes to Requirements, Task and Bugs.