DEV Community

Cover image for How to Manage Git Branches for Jira Tickets in IntelliJ IDEA
Abassi Sabri
Abassi Sabri

Posted on

How to Manage Git Branches for Jira Tickets in IntelliJ IDEA

Introduction

This tutorial guides you through effectively managing Git branches for your Jira tickets using IntelliJ IDEA. This approach streamlines collaboration, tracks changes, and ensures a clean development workflow.

Prerequisites

  • Basic understanding of Git commands
  • Project connected to a Git repository (e.g., GitHub, GitLab)
  • Active Jira account with a project integrated with your Git repository (optional but highly recommended)

Creating a Branch per Jira Ticket

  1. Open the Version Control (VCS) Menu: In IntelliJ IDEA, navigate to Git >.
  2. Create a New Branch: Select New Branch.
  3. Name Your Branch: Use a descriptive naming convention reflecting the Jira ticket.
    A common pattern is feature/-, for example, feature/ABC-123-add-user-login. This practice improves clarity and traceability.

  4. Checkout the New Branch: Select Checkout to start working on your changes in the new branch. This isolates your development from the main codebase.

Equivalent Git Commands :

git checkout -b feature/ABC-123-add-user-login  # Creates and switches to the new branch
Enter fullscreen mode Exit fullscreen mode

Making Changes and Committing

  1. Code Edits: Make your code modifications related to the Jira ticket in the designated branch.
  2. Commit Your Changes: When ready, go to Git > Commit or use the commit icon in the toolbar.
  3. Write a Clear Commit Message: Describe your changes concisely, often referencing the Jira ticket ID for easier tracking. A good format follows the conventional style: (): . Example: fix(ABC-123): Implemented user login functionality.
  4. Pushing Changes to Remote Repository : Push to Remote Repository: If you're collaborating with others and want to share your local branch, go to Git > Push. Select the remote repository and the branch you want to push to (usually origin and your branch name).

Equivalent Git Commands :

git add modified-file-1 modified-file-2 
git commit -m "Message"
git push origin feature/ABC-123-add-user-login
Enter fullscreen mode Exit fullscreen mode

Merging into main after validation

Merge feature into main

Once you've completed work on your feature branch, received validation/testing approval, it's time to integrate your changes into the main branch. Here's how to achieve this :

Let's startby downloading the latest changes from the remote repository, then switching to the main branch for local work :

git fetch && git checkout main
Enter fullscreen mode Exit fullscreen mode

Now Merge the feature branch into you main branch ! (If there is a conflict resolve it then remerge).

Git merge with Intellij

Thanks for reading!

Top comments (0)