Tutorials

Create a commit and pull request with Bob

Use Bob to create a branch, stage changes, generate a commit message, push to your repository, and open a pull request.

Bob has built-in support for Git version control and lets you manage your code changes without leaving the IDE.

In this tutorial, you use Bob to create a branch, stage code changes, generate a descriptive commit message, push the changes to your repository, and open a pull request that you can review and merge.

Prerequisites

Set up the project

Prepare a working copy of the repository.

Fork the repository

You will work from a fork of the Galaxium Travels repository.

  1. Go to the Galaxium Travels repository on GitHub.
  2. Click the Fork button in the top-right corner of the page.
  3. Select your GitHub account as the owner of the fork.

To learn more about forking a repository, see GitHub's documentation on forking a repository.

Clone the repository

  1. In a terminal, clone the forked Galaxium Travels repository. Replace <your-id> with your GitHub username in the following command:

    git clone git@github.com:<YOUR_ID>/galaxium-travels.git

If you get an authentication error, ensure you have added your SSH key to the ssh-agent. See GitHub's documentation for more information.

  1. In Bob, click File then Open Folder.

  2. Navigate to the galaxium-travels directory you just cloned and open it.

Switch to Agent mode

If the Bob chat interface is not already opened, open it by clicking the Bob icon beside the navigation bar or use the shortcut Option + Command + B (Mac) or Ctrl + Alt + B (Windows).

Bob chat panel open in IBM Bob IDE

Use Agent mode so Bob can write and modify code, run Git commands, and guide you through the workflow. Bob still asks for permission before each operation unless explicitly allowed.

Click the mode selector drop-down in the agentic chat and select Agent, or type /agent in the chat.

Create a branch

Before making changes, create a feature branch so your work stays separate from main.

Run the following prompt:

Create and switch to a new branch named update-header.

Bob requests permission to run git checkout -b update-header.

Click Approve for task to create the branch and switch to it.

Make a code change

Make a small change to give Bob something to commit.

Open the Header component

In the Galaxium Travels codebase, open booking_system_frontend/src/components/layout/Header.tsx.

Edit the header text

Ask Bob to make the change Galaxium Travels to Galaxium Travel Agency. The @ prefix adds a file to Bob's context so it knows exactly which file to edit.

Change the name of the Header from `Galaxium Travels` to `Galaxium Travel Agency` 
in @booking_system_frontend/src/components/layout/Header.tsx

Alternatively, you can manually edit the file and change Galaxium Travels to Galaxium Travel Agency.

<span className="text-2xl font-bold bg-cosmic-gradient bg-clip-text text-transparent">
    Galaxium Travel Agency
</span>

Run the Git workflow

Use Bob to stage, commit, push your changes, and then open a pull request.

Stage your changes

Run the following prompt to stage your changes:

Stage all the changes I made for the header component update.

Bob inspects the working tree, identifies the modified files, and requests permission to run git add.

Click Approve for task to allow Bob to run the command.

Commit your changes

Run the following prompt to commit the staged changes:

Commit the staged changes with a descriptive commit message that summarizes what was added.

Bob reviews the staged diff and generates a commit message that describes the purpose and scope of the changes.

Bob displays a permission prompt in the IDE to run Execute commands.

Click I understand the risks, then click Approve so Bob can run git commit.

Push the changes

Run the following prompt to push your commit to the remote repository:

Push my changes to the remote repository.

Bob identifies the current branch and remote, then requests permission to run git push.

Click Approve for task to push the commit. Bob confirms the push succeeded in the chat history.

Open a pull request

Run the following prompt to create a pull request:

Create a pull request to merge my changes into the main branch. Write a clear title and description based on what was changed.

Bob requires GitHub authentication the first time you create a pull request. Bob opens a browser window for you to authorize access. Once you authorize, Bob opens the pull request. Click the provided link to access the pull request in your browser. After reviewing the title and description, click Create pull request.

Bob returns the pull request URL so you can review, share, or merge it directly from your browser.

To have Bob create pull requests without a confirmation window, install the GitHub CLI and ask Bob to use it to create pull requests.

Troubleshooting

  • Push rejected or authentication failed: Confirm Git is configured with credentials that can push to your fork.
  • Branch update-header already exists: Ask Bob to switch to the existing branch or choose another branch name.
  • Pull request targets IBM/galaxium-travels: Change the base repository to your fork before creating the pull request.

Clean up

After completing this tutorial, you can remove the resources you created:

  • Switch your local clone back to the main branch.
  • Close or merge the pull request on GitHub.
  • Delete the update-header branch from your fork.
  • Delete your fork of Galaxium Travels if you no longer need it.

Next steps

In this tutorial, you learned how to use Bob's native Git integration to manage your code changes without leaving the IDE.

Advance to Standardize Bob's behavior to learn how to define persistent rules that control Bob's behavior across every conversation and mode.

How is this topic?