agentleFS
Cogni-AI-OUCogni-AI-OU/cogni-ai-agent-skills/git-rebase/SKILL.md

git-rebase

Skill4 starsChanged 6 months agoMITView on GitHub

Advanced Git rebase operations including interactive history cleanup and non-interactive scripted rewrites. You MUST load this skill before performing Git rebase operations.

  • Deletes or force-pushes
  • Commits and pushes

8 other projects use a version of this.

Adopted by

Most recently taken up by

The file

We split this skill into the rules it gives an agent

4 rules. 0 are common, 3 are distinctive, and 1 is very specific to this project.

  • 0

    Common

    Most of the 6 edited versions we read keep these.

  • 3

    Distinctive

    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
  • could be automatic: a setting could enforce it
  1. Distinctive:

    When updating a feature branch with the latest changes from main to maintain a linear history.

    line 17
  2. Distinctive:

    When moving a branch's base from one commit to another to untangle dependency chains.

    line 19
  3. Very specific:

    Start manual rebase: git rebase -i <base-commit-or-branch>

    line 38
  4. Distinctive:

    NEVER rebase commits that have already been pushed to a shared public branch unless explicitly coordinating a force-push.

    line 45

“Common” is measured: kept by at least 6 in 10 of the 6 edited versions of this file we could read. “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
SKILL.md
<!-- markdownlint-disable MD013 MD023 MD031 MD032 -->

Git Rebase

Expert-level guidance for executing Git rebase operations safely, particularly distinguishing between interactive manual usage and automated environments.

When to Use

  • When updating a feature branch with the latest changes from main to maintain a linear history.
  • To squash or fix up messy, intermediate commits before opening a Pull Request (using git rebase -i --autosquash locally).
  • When moving a branch's base from one commit to another to untangle dependency chains.

When Not to Use

  • On shared or public branches where other developers have already pulled the commits (doing so rewrites history and causes severe integration headaches).
  • For simple feature integrations where a standard merge commit is explicitly requested or preferred by the team's workflow.
  • In fully automated CI/CD environments unless strictly using non-interactive scripting to handle specific autosquash patterns.

Common Pitfalls

  • Interactive Terminal Hangs: Using -i in an automated agent environment, causing the system to freeze while waiting for a VIM editor input that will never happen.
  • Force-Pushing Blindly: Running git push --force after a rebase instead of git push --force-with-lease, potentially destroying a teammate's recent commits.
  • Conflict Panic: Encountering a merge conflict during a rebase and running chaotic commands instead of methodically resolving the files, adding them, and running git rebase --continue (or --abort if hopelessly stuck).

Interactive Rebasing (git rebase -i)

  • Objective: Clean up local commit history before pushing.
  • Process:
    • WARNING: Interactive modes (-i) are FORBIDDEN in runtime automation. Ensure -i is strictly scoped to local manual-only usage or fixing in the non-GitHub runtime (like in local agent or devcontainer runtime).
    • Start manual rebase: git rebase -i <base-commit-or-branch>
    • Non-interactive note: GIT_SEQUENCE_EDITOR=true only skips opening the editor; it does not rewrite the rebase todo list.
    • Scripted rewrites: For automation, set GIT_SEQUENCE_EDITOR to a script or command that edits the todo file, or prefer git rebase -i --autosquash with fixup! / squash! commits when appropriate.
    • Actions in the todo list: pick, reword, edit, squash (or s), fixup (or f), drop.

Safety Principles

  • NEVER rebase commits that have already been pushed to a shared public branch unless explicitly coordinating a force-push.
  • Abort: Execute git rebase --abort to safely cancel an ongoing rebase operation.

What to Avoid

  • Interactive command execution (git rebase -i) in automated runtime pipelines.

Limitations

  • Cannot autonomously perform interactive rebasing in restricted runtime environments.

Related Skills

  • git: You MUST load this skill when performing standard Git operations.
  • git-expert: You MUST load this skill when performing advanced Git operations beyond rebasing.

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.