Chapter 3 - Git Intermediate Concepts

Branching Strategies

Branching in Git allows multiple developers to work on different tasks simultaneously without interfering with each other’s work. Here are some common strategies:

  • Feature Branching: Create branches for each new feature to keep changes isolated from the main codebase.
  • Release Branching: Maintain separate branches for release candidates, allowing for bug fixes and preparation for a production release.
  • Hotfix Branching: Quickly create branches to address urgent bugs in production code.

Each strategy serves a specific purpose and can be chosen based on the team’s workflow and project requirements.

Types of Merging

Merging is the process of integrating changes from one branch into another. Git offers several types of merges:

  • Fast-Forward Merge: Moves the base branch pointer forward until it equals the feature branch’s pointer.
  • Three-Way Merge: Used when two branches have diverged. A new “merge commit” is created to join the two histories.
  • Squash Merge: Combines all feature branch commits into a single commit for a cleaner history when merging into the base branch.

Understanding the implications of each merge type is crucial for maintaining a coherent project history.

Important Concepts

Other intermediate concepts of version control include:

  • Pull Requests (PRs): PRs are a feature of hosting services like GitHub and GitLab. They let you tell others about changes you’ve pushed to a branch in a repository.
  • Workflows: Workflows like Gitflow and GitHub Flow offer structured methods for branching and merging that fit different types of projects and development cycles.
  • Rebasing: Rebasing is an alternative to merging, rewriting the commit history to produce a straight, linear progression of changes.
  • Stashing: Save uncommitted changes in a stack while you switch branches.

By mastering these concepts, developers can collaborate more effectively and maintain a clean, functional codebase.

References

Expand 1. Atlassian. “A Guide to Optimal Branching Strategies in Git.” Atlassian, www.atlassian.com/agile/software-development/branching. Accessed 15 Apr. 2024.
2. Marijan, Bosko. “Git Branching Strategies: What Are Different Branching Strategies?” Knowledge Base by phoenixNAP, 19 Dec. 2023, phoenixnap.com/kb/git-branching-strategy.
3. Merrett, Luke. “Different Merge Types in Git.” Luke Merrett, 7 Aug. 2021, lukemerrett.com/different-merge-types-in-git.
4. “About Merge Methods on Github.” GitHub Docs, docs.github.com/en/repositories/configuring-branches-and-merges-in-your-repository/configuring-pull-request-merges/about-merge-methods-on-github. Accessed 15 Apr. 2024.
5. Price, Taylor R. “Git Merge: To Squash or Fast-Forward?” DEV Community, 23 Mar. 2023, dev.to/trpricesoftware/git-merge-to-squash-or-fast-forward-3791.
6. Wright, Mitchell. “What Is Version Control? 13 Key Concepts & Terms to Know.” BloomTech, 28 Feb. 2024, www.bloomtech.com/article/version-control-vocabulary.
7. “About Pull Requests.” GitHub Docs, docs.github.com/en/pull-requests/collaborating-with-pull-requests/proposing-changes-to-your-work-with-pull-requests/about-pull-requests. Accessed 15 Apr. 2024.
8. “About Git Rebase.” GitHub Docs, docs.github.com/articles/about-git-rebase. Accessed 15 Apr. 2024.