home / skills / toilahuongg / shopify-agents-kit / git-sync

git-sync skill

/.claude/skills/git-sync

This skill helps you keep your local branch up to date with the remote by performing fetch and pull --rebase, resolving conflicts as needed.

npx playbooks add skill toilahuongg/shopify-agents-kit --skill git-sync

Review the files below or copy the command above to add this skill to your agents.

Files (1)
SKILL.md
544 B
---
name: git-sync
description: Sync with remote repository using pull --rebase. Use when you need to update your local branch with remote changes.
disable-model-invocation: true
allowed-tools: Bash(git:*)
---

# Git Sync

Sync local branch with remote using rebase.

1. Fetch the latest changes from the remote repository.
   - Command: `git fetch origin`

2. Pull and rebase the current branch on top of the remote branch.
   - Command: `git pull origin HEAD --rebase`
   - If there are conflicts, resolve them, then `git rebase --continue`.

Overview

This skill syncs your local Git branch with the remote repository using a pull with rebase. It helps keep a clean linear history by rebasing your local commits on top of the latest remote changes. Use it when you want to update your working branch without creating merge commits.

How this skill works

The skill first fetches the latest objects and refs from the remote (git fetch origin). Then it performs a pull that rebases the current branch onto the corresponding remote HEAD (git pull origin HEAD --rebase). If rebase conflicts occur, resolve the conflicts in your files and run git rebase --continue to finish the process.

When to use it

  • Before pushing local changes to ensure you base your work on the latest remote commits.
  • When you prefer a linear history without merge commits on feature branches.
  • In CI/CD or pre-merge workflows where rebasing is required or recommended.
  • When collaborating on a shared branch where others push frequently.

Best practices

  • Always commit or stash local work before fetching and rebasing to avoid losing uncommitted changes.
  • Run git fetch origin first to inspect incoming changes with git log or git diff before rebasing.
  • If conflicts appear, resolve them carefully, test the code, then run git rebase --continue.
  • Avoid rebasing public branches that others also base work on; prefer rebasing private or feature branches.
  • If rebase goes wrong, use git rebase --abort to return to the pre-rebase state.

Example use cases

  • You finished a small feature locally and want to update your branch with remote changes before pushing.
  • A teammate pushed fixes to the same branch; rebase your commits to place them on top of those fixes.
  • Preparing a pull request and ensuring the commit history is linear and contains no merge commits.
  • Automated scripts that synchronize developer branches with the remote prior to running tests.

FAQ

What if I encounter merge conflicts during rebase?

Open the conflicting files, resolve the conflicts, stage the changes with git add, then run git rebase --continue. Use git rebase --abort to cancel if needed.

Can I rebase a branch that others already use?

Rebasing rewrites history and can disrupt collaborators. Avoid rebasing branches shared by others; instead use merge in that case.