Skip to content

Rebase and merge

Dianjin Wang edited this page Mar 13, 2026 · 4 revisions

GitHub may show:

This branch cannot be rebased due to conflicts

This does NOT mean your pull request is broken. This typically happens when you have a large pull request with more than 100 commits or duplicated histories. It only affects GitHub’s UI merge method. We can merge via CLI.

Note

This workflow requires committer push access.

Background

For Apache Cloudberry release branches (e.g., REL_2_STABLE), we prefer a controlled and reproducible merge process.

Manual merging allows us to:

  • Preserve release branch stability
  • Keep CI traceability
  • Handle large PRs that GitHub UI cannot rebase automatically

Assumptions

  • Target branch: REL_2_STABLE
  • PR branch: pr-branch
  • You have push access to the Apache Cloudberry repository

Workflow

Step 1: Download the Cloudberry Source Files

git clone git@github.com:apache/cloudberry.git
cd cloudberry

Step 2: Fetch PR Branch

git fetch origin pull/pr-id/head:pr-branch
git checkout pr-branch

Rebase PR onto the target branch (Recommended. This rewrites the PR branch history. Resolve conflicts if any.):

git rebase origin/REL_2_STABLE

Step 3: Update the Target Branch

git checkout REL_2_STABLE
git pull origin REL_2_STABLE

Step 4: Merge the PR into the Release Branch

git merge --ff-only pr-branch

Step 5: Final Validation (Pre-push Check)

Before pushing to the remote repository, perform a final check to ensure the local REL_2_STABLE is clean and contains no merge commits.

# 1. Ensure no merge commits exist in the commits about to be pushed
# Expected output: EMPTY
git rev-list --merges origin/REL_2_STABLE..HEAD

# 2. Verify the local branch is ahead of origin/REL_2_STABLE and linearly integrated
# Expected output: "Ready to push"
git merge-base --is-ancestor origin/REL_2_STABLE HEAD && echo "Ready to push"

Step 6: Push to the Release Branch

git push origin REL_2_STABLE

References

Clone this wiki locally