DEV Community

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

Posted on

2

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!

👋 One last chance before you go!

It takes one minute to join DEV and is worth it for your career.

You get 3x the value by signing in instead of lurking

Get started

Community matters

Top comments (0)

A Workflow Copilot. Tailored to You.

Pieces.app image

Our desktop app, with its intelligent copilot, streamlines coding by generating snippets, extracting code from screenshots, and accelerating problem-solving.

Read the docs

👋 Kindness is contagious

Explore a sea of insights with this enlightening post, highly esteemed within the nurturing DEV Community. Coders of all stripes are invited to participate and contribute to our shared knowledge.

Expressing gratitude with a simple "thank you" can make a big impact. Leave your thanks in the comments!

On DEV, exchanging ideas smooths our way and strengthens our community bonds. Found this useful? A quick note of thanks to the author can mean a lot.

Okay