본문으로 건너뛰기
cccskills
무료GitHub에 공개

rebase-onto-main

Rebase a branch onto main, handling squash-merged parent branches cleanly

한국어 요약은 준비 중입니다. 원문 설명을 표시하고 있습니다.

mengchaoheng/DuctedFanUAV-Autopilot스타 19(GitHub 19 + cccskills 0)

실행 점수 미검증

설치 방법 보기

포함된 파일(1)

  • SKILL.md2.4 KB

SKILL.md(원문)

설치하기 전에 에이전트에게 전달되는 지시 내용을 확인할 수 있습니다.

Rebase Branch onto Main

Rebase the current (or specified) branch onto main, correctly handling the case where the branch was built on top of another branch that has since been squash-merged into main.

Background

When a parent branch is squash-merged, its individual commits become a single new commit on main with a different hash. A normal git rebase main will try to replay the parent's original commits, causing messy conflicts. The fix is to cherry-pick only the commits unique to this branch onto a fresh branch from main.

Steps

  1. Identify the branch. Use $ARGUMENTS if provided, otherwise use the current branch.

  2. Fetch and update main:

    git fetch origin main:main
    
  3. Find the merge base between the branch and main:

    git merge-base <branch> main
    
  4. List all commits on the branch since the merge base:

    git log --oneline <merge-base>..<branch>
    
  5. Identify which commits are unique to this branch vs. inherited from a parent branch. Look for:

    • Squash-merged commits on main that correspond to a group of commits at the bottom of the branch's history (check PR titles, commit message keywords).
    • The boundary commit: the first commit that belongs to this branch's work, not the parent's.
    • If ALL commits are unique (no parent branch), just do a normal git rebase main and skip the rest.
  6. Create a fresh branch from main:

    git checkout -b <branch>-rebase main
    
  7. Cherry-pick only the unique commits (oldest first):

    git cherry-pick <first-unique-commit>^..<branch>
    

    The A^..B range means "from the parent of A through B inclusive."

  8. Handle conflicts if any arise during cherry-pick. Resolve and git cherry-pick --continue.

  9. Replace the old branch:

    git branch -m <branch> <branch>-old
    git branch -m <branch>-rebase <branch>
    
  10. Verify the result:

    git log --oneline main..<branch>
    

    Confirm only the expected commits are present.

  11. Ask the user before force-pushing. When approved:

    git push origin <branch> --force-with-lease
    
  12. Clean up the old branch:

    git branch -D <branch>-old
    

리뷰

아직 리뷰가 없습니다. 사용해 본 소감을 남겨 주세요.

댓글

로그인 없이 쓸 수 있습니다. 사용 후기, 질문, 작동하지 않은 환경 등을 편하게 남겨 주세요.

아직 댓글이 없습니다. 첫 댓글을 남겨 보세요.

보내면 바로 공개됩니다. 이메일 주소나 전화번호 같은 개인 정보는 쓰지 마세요. URL은 2개까지입니다.

0 / 1,000자

이 양식은 reCAPTCHA로 보호되며 Google 개인정보처리방침 및 서비스 약관이 적용됩니다.

같은 저장소의 스킬

commit

무료

Create a conventional commit for PX4 changes

한국어 요약은 준비 중입니다. 원문 설명을 표시하고 있습니다.

mengchaoheng/DuctedFanUAV-Autopilot192026년 10월 30일 업데이트

pr

무료

Create a pull request with conventional commit title and description

한국어 요약은 준비 중입니다. 원문 설명을 표시하고 있습니다.

mengchaoheng/DuctedFanUAV-Autopilot192026년 10월 30일 업데이트

review-pr

무료

Review a pull request with structured, domain-aware feedback

한국어 요약은 준비 중입니다. 원문 설명을 표시하고 있습니다.

mengchaoheng/DuctedFanUAV-Autopilot192026년 10월 30일 업데이트

mengchaoheng의 스킬 모두 보기

이 스킬의 문제 신고