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
- Open the Version Control (VCS) Menu: In IntelliJ IDEA, navigate to Git >.
- Create a New Branch: Select New Branch.
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.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
Making Changes and Committing
- Code Edits: Make your code modifications related to the Jira ticket in the designated branch.
- Commit Your Changes: When ready, go to Git > Commit or use the commit icon in the toolbar.
- 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.
- 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
Merging into main after validation
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
Now Merge the feature branch into you main branch ! (If there is a conflict resolve it then remerge).
Thanks for reading!
Top comments (0)