agentsclimarketplace

Git update branch

Skill MAHDTech/agent-skills/skills/github/git-update-branch

Make AI Agents great again!

Install
npx -y skills add MAHDTech/agent-skills --skill git-update-branch

Assembled from the repository path, not quoted from the project. Check it against their README if it does not work.

One thing to look at

  • 0 stars0 stars. Stars are a popularity signal and not a quality one, but at this level it is likely that nobody has read this closely except its author, and you would be relying on your own review.

What its author says it does

Copied from the file, not written here

Bring a feature branch up to date with its base branch safely — fetch first, detect the base, choose rebase vs merge deliberately, use --force-with-lease, and hand conflicts off cleanly. Use when a branch has fallen behind its base, when the user wants to rebase or merge in the latest from the base/default branch, when a PR reports merge conflicts or an out-of-date branch, or when deciding between rebase and merge for an update.

SKILL.md

4.0 KB, 833 tokens by cl100k_base, as published. Nobody here has run it

Update a Branch Against Its Base

Sync a feature branch with the base branch it will merge into, choosing the integration strategy deliberately and doing it without clobbering anyone's work.

When the update stops on conflicts, hand off to /git-resolve-conflicts.

1. Fetch and detect the base

Always fetch first so you integrate against the true remote tip, not a stale local copy:

git fetch origin --prune

Detect the base branch — do not assume main or master. If the user named one, use it. Otherwise try in order until one succeeds:

BASE=$(gh repo view --json defaultBranchRef -q '.defaultBranchRef.name' 2>/dev/null)
BASE=${BASE:-$(git remote show origin 2>/dev/null | sed -n 's/.*HEAD branch: //p')}
BASE=${BASE:-$(git symbolic-ref refs/remotes/origin/HEAD 2>/dev/null | sed 's@^refs/remotes/origin/@@')}

If a PR exists, its baseRefName is authoritative: gh pr view --json baseRefName -q '.baseRefName'. If detection fails, ask the user rather than guessing.

2. Secure the working tree

An update rewrites or moves your checkout, so start clean:

git status --short

If there are uncommitted changes, commit them or git stash push first, and restore with git stash pop after the update. Never start a rebase or merge with a dirty tree.

3. Choose rebase vs merge

FactorRebaseMerge
HistoryLinear — replays your commits on top of the basePreserves both histories, adds a merge commit
Shared-branch safetyUnsafe — rewrites your commit SHAsSafe — never rewrites existing commits
ConflictsMay resurface per replayed commitResolved once, in the merge commit
Push afterNeeds --force-with-leasePlain git push

The golden rule: never rebase a branch other people have based work on or pulled. Rewriting shared history forces every collaborator to recover their copy by hand. If anyone else is building on this branch, merge.

Default: rebase a solo, unshared feature branch to keep history linear; merge when the branch is shared, or when preserving the exact integration history matters more than a clean line.

4. Integrate

Rebase onto the freshly fetched base tip:

git rebase "origin/$BASE"

Merge the base in:

git merge "origin/$BASE"

To bail out at any point and return to the pre-update state, use git rebase --abort or git merge --abort.

5. Handle conflicts

If the rebase or merge stops with conflicts, stop and invoke /git-resolve-conflicts to work through them. After it stages the resolutions, continue with git rebase --continue (repeat until the replay finishes) or git commit to seal the merge.

6. Push

After a merge, push normally:

git push

After a rebase, the remote branch and your rewritten local branch have diverged, so push with a lease — never a bare --force:

git push --force-with-lease

--force-with-lease refuses the push if the remote moved since your last fetch, protecting a collaborator's commits you have not seen; a plain --force overwrites them unconditionally. If the lease is rejected, re-fetch, reconcile, and only then push again.

Done when the branch contains the base's latest commits, the tree is clean, and the push succeeds.

What ships with it

Read from the repository

Just SKILL.md. No reference files, no scripts.

Keep looking

Skills are one crate of 328,083. Ordering is by how many stacks a row turns up in, so the top of any crate is what has actually been picked rather than what has the most stars.