Rebase Current Branch
GitHubOfficialFirst committed by ContinuousCaffeniationDistributed by GitHub
- Skill
- Workflow
- Software development
- MIT
- No issues found
AutoGineer summary
Written by AutoGineer from the skill’s own files, not by the author
This skill provides a structured, safe procedure for updating a local feature branch by rebasing it onto the latest version of the repository's default branch. It prioritizes safety by verifying the repository state, detecting the correct default branch name (e.g., main or master), and handling potential conflicts through user-guided resolution rather than automated force-overwriting.
What it does
- Detects the repository's actual default branch name automatically.
- Fetches the latest updates from the remote upstream.
- Performs a rebase of the current branch onto the remote-tracking default branch.
- Provides a safe, interactive process for resolving merge conflicts.
- Offers to run local validation hooks or tests after a successful rebase.
- Ensures uncommitted work is protected by checking the working tree status first.
When to use it
- When you need to sync your feature branch with the latest changes from the main codebase.
- Before submitting a pull request to ensure your branch is up to date.
- When you are asked to update your branch with the latest upstream master or main branch.
- When you want to maintain a clean commit history by rebasing instead of merging.
Advantages
- Prevents accidental data loss by checking for uncommitted changes before starting.
- Avoids assumptions about branch naming conventions.
- Promotes a clean, linear project history.
- Includes built-in safety checks to prevent force-pushing or discarding work.
Usage examples
- “Update my current branch with the latest changes from main.”
- The agent identifies the upstream default branch, fetches the latest commits, and rebases your current branch, pausing for your input if any conflicts arise.
- “Sync this feature branch before I open a pull request.”
- The agent verifies your working tree, fetches the remote updates, performs the rebase, and offers to run your project's test suite to ensure the rebase didn't break anything.
Install
Download the skill as a ZIP:
https://mp-staging.autogineer.com/agent-skills/github/rebase-current-branch/downloadUnzip it into the cross-client skills folder of your project:
mkdir -p .agents/skills && unzip rebase-current-branch.zip -d .agents/skills
Documentation by ContinuousCaffeniation
Rebase the Current Branch
Update the active branch by replaying its commits on top of the latest default branch from its upstream remote. Use the repository's actual default branch, whether it is named main, master, or another branch.
Workflow
Inspect before changing anything. Run
git status --porcelain=v1 --branch --untracked-files=allandgit branch --show-current. Confirm the current branch is not the default branch and note any local changes. If the working tree has changes, stop and ask the user whether to commit, stash, or otherwise handle them. Do not stash automatically.Identify the upstream and default branch. Check
git remote -vandgit remote show <remote>(or the remote's symbolicHEAD) to determine the branch this repository treats as its default. Prefer the configured upstream for the current branch when available; otherwise useorigin. Do not assume thatmainexists or that a branch namedmasteris current. If the default branch cannot be identified unambiguously, ask the user.Fetch the latest default branch. Fetch only the identified remote and default branch, for example:
git fetch <remote> <default-branch>Verify the fetched remote-tracking ref exists before continuing.
Rebase the active branch. Tell the user which branch will be rebased onto which remote-tracking branch, then run:
git rebase <remote>/<default-branch>Handle conflicts without discarding work. If the rebase stops, explain which files conflict and that the rebase is paused. Resolve only when the intended changes are clear; otherwise ask the user. After resolution, stage the resolved files and run
git rebase --continue. If the user wants to abandon the operation, rungit rebase --abort. Never usegit reset --hard, discard user changes, or skip commits to force completion.Offer validation hooks. After the rebase succeeds, inspect the repository's documented validation steps and configured hooks (for example, pre-commit hooks or lint and test scripts). Ask the user whether they want those checks run before proceeding. If they agree, run the applicable checks and report their results; do not bypass or disable hooks.
Verify the result. When the rebase completes, run
git status --porcelain=v1 --branch --untracked-files=alland summarize the outcome, including the base branch used, validation results if run, and any remaining changes. Do not push, force-push, or amend commits unless the user separately asks.
Quick Path
For a clean working tree where the upstream default branch is known, the core operation is:
git fetch <remote> <default-branch>
git rebase <remote>/<default-branch>Replace <default-branch> with the detected branch name (main, master, or another configured default). Never run the placeholder commands literally.
Safety Rules
Preserve the user's current branch and uncommitted work.
Do not rebase the default branch itself.
Do not assume local
mainormasteris up to date; rebase onto the fetched remote-tracking branch.Do not push or force-push as part of this workflow.
If a rebase is already in progress, inspect its state and ask whether to continue or abort; do not start another rebase.
Files
- ATTRIBUTION.mdAdded by AutoGineer860 B
- LICENSELicence file added by AutoGineer1.0 KiB
- SKILL.md3.6 KiB
Requirements and compatibility
Written for: GitHub Copilot
Works with: Claude Code, Claude apps, OpenAI Codex, GitHub Copilot, Cursor, Gemini CLI, Kiro, OpenCode, Goose, Amp, Roo Code, JetBrains Junie, Factory Droid, Devin (ex-Windsurf), Mistral Vibe, OpenHands, Letta
“Works with” means the tool reads the open Agent Skills format; a skill written for one tool may use features others lack.
Needs: Declares allowed tools, Needs a command-line tool
Security
No issues found by our static scan· No issues found
A static scan is not a guarantee. Skills are third-party content: review a skill before you let an agent use it.
Attribution and licence
- First committed by
ContinuousCaffeniation
- Publisher
- GitHub (Official)
- Distributed by
- GitHub
- Source
- github/awesome-copilot · skills/rebase-current-branch · commit 797337f
- Licence
- MIT License (redistribution allowed)
- LICENSE (added by AutoGineer from LICENSE)
- ATTRIBUTION.md (written by AutoGineer)
- Synced
- Contributors
- ContinuousCaffeniation
AutoGineer is not affiliated with or endorsed by ContinuousCaffeniation or GitHub.
Download ZIP
The ZIP holds the skill’s files, its licence files and an ATTRIBUTION.md. Download rebase-current-branch.zip