update-from-main

zmchenry's avatarfrom zmchenry

Updates the current branch with the latest changes from origin/main using rebase. Use when the user asks to update, sync, or rebase their branch with main/master.

⭐0stars🔀0forks📁View on GitHub🕐Updated Jan 9, 2026

When & Why to Use This Skill

This Claude skill automates the process of synchronizing a local Git branch with the latest changes from the main repository using rebase. It streamlines developer workflows by handling fetching, rebasing, and conflict management, ensuring a clean commit history and reducing manual CLI overhead for version control maintenance.

Use Cases

  • Synchronizing a feature branch with the latest upstream changes from origin/main to prevent integration issues before a pull request.
  • Maintaining a clean and linear git commit history by rebasing local work onto the master branch instead of creating unnecessary merge commits.
  • Guided conflict resolution during the rebase process, providing step-by-step instructions to resolve code discrepancies and continue the update.
  • Automating the 'fetch and rebase' workflow to ensure the local development environment is always aligned with the team's primary codebase.
nameUpdate from Main
descriptionUpdates the current branch with the latest changes from origin/main using rebase. Use when the user asks to update, sync, or rebase their branch with main/master.

Update from Main

This skill helps update the current branch with the latest changes from origin/main using git rebase.

Quick Start

When the user requests to update their branch with main:

  1. Check the current branch name
  2. Ensure working directory is clean (no uncommitted changes)
  3. Fetch latest changes from origin
  4. Rebase current branch onto origin/main
  5. Handle any conflicts that arise

Instructions

Step 1: Check current state

# Get current branch name
git branch --show-current

# Check for uncommitted changes
git status

If there are uncommitted changes, ask the user if they want to:

  • Commit them first
  • Stash them
  • Abort the operation

Step 2: Fetch latest changes

# Fetch all latest changes from origin
git fetch origin

Step 3: Rebase onto origin/main

# Rebase current branch onto origin/main
git rebase origin/main

Step 4: Handle conflicts

If conflicts occur during rebase:

  1. Show the conflicting files:
git status
  1. Inform the user about the conflicts and list the files

  2. Explain that they need to:

    • Resolve conflicts manually
    • Run git add <file> for each resolved file
    • Run git rebase --continue
    • Or run git rebase --abort to cancel
  3. Offer to help resolve conflicts if the user requests it

Step 5: Confirm success

After successful rebase:

# Show the updated status
git status

# Show recent commits to verify
git log --oneline -5

Inform the user that:

  • The branch has been successfully updated with changes from origin/main
  • If the branch was previously pushed, they may need to force push: git push --force-with-lease

Important Notes

  • Always check for uncommitted changes before starting
  • Use git rebase --abort if something goes wrong
  • Prefer git push --force-with-lease over git push --force for safety
  • If the user prefers merge over rebase, use git merge origin/main instead

Alternative: Merge instead of Rebase

If the user explicitly prefers merge or if rebase fails repeatedly:

git fetch origin
git merge origin/main

This creates a merge commit instead of rewriting history.

Common Issues

  • "cannot rebase with uncommitted changes": Stash or commit changes first
  • Conflicts during rebase: Help user resolve them or abort and try merge
  • Already up to date: Inform user no changes were needed