Branching and Merging in Git (NBKRIST)

1. Why Branching is Important in Real-Time Projects

In real-world Agile development, multiple features or bug fixes are often worked on simultaneously. Branching allows developers to create isolated environments for each task without disturbing the main codebase.

A software engineer uses branches to manage parallel work — feature, hotfix, and release branches. It supports better team collaboration and ensures controlled integration through pull requests and merges.

Branches can be easily created, switched, merged, or deleted — forming a simple yet powerful workflow model for modern software development.

Branching Importance in Agile

2. What is a Branch in Git?

A branch represents an independent line of development in Git. It allows you to work on new features or bug fixes without affecting the main project.

The default branch is usually called main or master, and developers can create multiple branches as needed.

Git Branch Structure

3. Creating a New Branch

Use the following command to create a new branch and switch to it:

git checkout -b feature-login

This creates a new branch named feature-login and prepares your workspace for development.

Creating New Branch

4. Switching Between Branches

You can easily move between branches using the checkout command. This helps you maintain different development paths in parallel.

git checkout main

In NBKRIST development tasks, this ensures students can test or integrate specific modules independently.

Switching Between Branches

5. Merging Branches

Merging brings changes from one branch into another. Typically, developers merge feature branches back into the main branch once tested.

git checkout main
git merge feature-login

This keeps the project codebase unified and up to date with all enhancements.

Merging Branches Example

6. Handling Merge Conflicts

When two developers modify the same part of a file, a merge conflict occurs. Git flags the conflict for manual resolution to preserve code integrity.

Resolving conflicts is part of every professional Git workflow — it builds collaboration discipline and clarity.

Merge Conflict Resolution

7. Deleting a Branch

Once a branch’s changes are merged and no longer needed, it’s best practice to delete it to keep the repository clean.

git branch -d feature-login

At NBKRIST, students are encouraged to maintain organized repositories to reflect industry-grade project standards.

Deleting Branch

8. Simple Software Workflow Example

Here’s a typical workflow: create a feature branch, commit changes, merge them to the main branch, and delete the feature branch.

git checkout -b feature-ui
# Make code changes
git add .
git commit -m "Added new UI feature"
git checkout main
git merge feature-ui
git branch -d feature-ui

This streamlined process ensures continuous delivery and controlled integration — essential for agile project success at NBKRIST.

Git Workflow Example