DPI Computing SocietyDPI Computing SocietyLearn, build, and grow together
Tutorial

Mastering Git & GitHub: Branching Strategies and Open Source Workflows

Level up your professional version control skills: interactive rebasing, semantic commit messages, GitHub Actions CI, and resolving complex merge conflicts.

TTahmid Hasan
1 min read
Mastering Git & GitHub: Branching Strategies and Open Source Workflows

Beyond git add . and git push

Most beginners learn three commands in Git: git add, git commit, and git push. But when you join a software engineering team or contribute to major open-source repositories, uncurated commit histories and messy merges become major liabilities.

In this guide, we break down industrial Git habits that will set you apart.


1. Trunk-Based Development vs GitFlow

GitFlow (Legacy for release cycles)

  • Complex branches: feature/*, develop, release/*, hotfix/*, main.
  • Tends to create long-lived branches that result in painful merge conflicts.

Trunk-Based Development (Modern Industry Standard)

  • Developers work in short-lived feature branches ($< 1-2$ days).
  • Branches are merged into main frequently through Pull Requests validated by automated CI tests.
  • Feature flags are used to hide uncompleted features in production.

2. Interactive Rebase: Clean History Before You Open a PR

Before submitting a Pull Request, squash your "wip", "fix typo", and "test" commits into clean, semantic units using interactive rebase:

# Rebase the last 4 commits
git rebase -i HEAD~4

In the editor:

pick e3f12a4 feat: add category filter to post manager
squash 9a2b1c3 fix typo in category schema
squash 4d5e6f7 format category files

3. Resolving Merge Conflicts with Confidence

When a conflict occurs:

  1. Don't panic: run git status to see the affected files.
  2. Open your diff tool or IDE.
  3. Understand the markers:
<<<<<<< HEAD (Current branch)
const category = await getCategoryById(id);
=======
const category = await fetchCategoryWithCount(id);
>>>>>>> feature/category-counts (Incoming branch)
  1. Edit the file to the desired state, remove the conflict markers, and complete the rebase:
git add src/lib/category.ts
git rebase --continue

4. Semantic Commit Messages

Adopt the Conventional Commits specification:

  • feat: add bilingual support for post titles
  • fix: prevent null pointer on empty category description
  • refactor: isolate database adapter to client singleton
  • docs: update readme with environment setup guide

Good version control hygiene reflects professional discipline and makes peer code reviews effortless.

Related posts