agentleFS
mchittinenimchittineni/cloud-platform-skills/.cursor/rules/skills/git-branching-merge-strategies.mdc

cloud-platform-skills / skills

Cursor rule1 starsChanged 4 months agoMITView on GitHub

Git workflow selection (trunk-based, GitHub Flow, GitFlow), rebase vs merge policy, interactive rebase hygiene, conflict resolution, and emergency recovery operations. Use when choosing a branching model, defining merge/rebase rules for a team, resolving conflicts, or recovering from a bad commit, push, or revert.

The file

We split this git-branching-merge-strategies.mdc into the rules it gives an agent

1 rule. About 0 are common, 0 are distinctive, and 1 is very specific to this project.

  • ≈0

    Common · estimate

    Many files like this have a rule of this kind.

  • ≈0

    Distinctive · estimate

    This author's own choices. Worth a look.

  • 1

    Very specific

    Tied to their project's names, files or tools. Probably skip.

  • Common
  • Distinctive
  • Very specific
  1. Very specific:

    If GitFlow is already in place and deploys are frequent, migrate incrementally: stop opening new long-lived feature branches first, then …

    line 95

≈ “Common” is an estimate: at least 1 in 5 of the 3,030 Cursor rule files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
git-branching-merge-strategies.mdc
---
description: Git workflow selection (trunk-based, GitHub Flow, GitFlow), rebase vs merge policy, interactive rebase hygiene, conflict resolution, and emergency recovery operations. Use when choosing a branching model, defining merge/rebase rules for a team, resolving conflicts, or recovering from a bad commit, push, or revert.
globs:
alwaysApply: false
---

# Git Branching, Rebase & Release Strategies

## When to Use This Skill

**Triggers — load this skill when:**

- A team needs a branching model chosen against its real deployment frequency
- You must define or enforce merge vs rebase and commit-hygiene policy in review
- Someone needs to undo, revert, stash, or recover work safely on a shared branch

**Route elsewhere when:**

- Pipeline triggers, gates, and required checks -> `cicd-pipeline-design`
- Git-as-source-of-truth for cluster state -> `gitops-multi-cluster-argo-flux`

## 1. Branching Strategy Selection

Choose the strategy appropriate for the team deployment frequency:

- **Trunk-Based Development (Recommended for CI/CD)**:
  - Short-lived feature branches (< 1-2 days).
  - Merged frequently into `main` via automated Pull Request checks.
  - Feature toggles (flags) used to hide incomplete features in production.
- **GitHub Flow**:
  - `main` is always deployable.
  - Feature branches branched off `main`, merged after code review and CI tests pass.

---

## 2. Rebase vs Merge Best Practices

### Clean Commit History via Interactive Rebase

```bash
# Keep feature branch up-to-date with main without merge bubbles
git checkout feature/auth-service
git fetch origin
git rebase origin/main

# Squash unneeded local micro-commits before opening PR
git rebase -i HEAD~4
```

### Safe Conflict Resolution

```bash
# In case of conflicts during rebase:
git status # identify conflicting files
# Edit conflicts, then:
git add <resolved-file>
git rebase --continue

# Abort cleanly if needed
git rebase --abort
```

---

## 3. Emergency Git Operations Runbook

```bash
# 1. Temporarily stash uncommitted changes with untracked files
git stash -u -m "WIP before hotfix switch"
git stash pop

# 2. Undo the last commit while keeping code changes staged
git reset --soft HEAD~1

# 3. Safely revert a faulty commit already pushed to main (creates inverse commit)
git revert <commit-sha>
```

---

## 4. Why Not GitFlow (Usually)

GitFlow's `develop` + `release/*` + long-lived `feature/*` model was designed for versioned
software shipped on a schedule to customers who install it. For a continuously deployed service
it adds two permanent merge fronts and delays integration, which is precisely where conflicts
and untested combinations accumulate.

| Model | Integration cadence | Fits |
| --- | --- | --- |
| Trunk-based (short-lived branches, <1 day) | Continuous | Continuous deployment, feature flags, high deploy frequency |
| GitHub Flow (branch + PR + deploy on merge) | Per PR | Most web services; the sensible default |
| GitFlow | Per release | Versioned/on-premise products with supported release lines and hotfix branches |
| Release branches only (`release/1.x`) | Per release line | Libraries and SDKs that must patch old majors |

If GitFlow is already in place and deploys are frequent, migrate incrementally: stop opening new
long-lived feature branches first, then collapse `develop` into `main` once the release cadence
is genuinely continuous. Adopting GitFlow because a diagram looked thorough is the anti-pattern.

Download now (ZIP)

Does it work?

Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.

No reviews yet

People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.

  • It worked
  • Partly
  • It didn't
What did you use it for? e.g. Reviewing pull requests in a Rails app

Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.

Your trail

Files you open will collect here, so you can find them again.

Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.

Now do this for your own.

Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.