| name | git-sync |
| description | Fetch and show remote changes without modifying local branch Use when this capability is needed. |
| metadata | {"author":"dtsong"} |
Scope Constraints
- Read-only operation — fetches remote refs and displays status but does not modify local branches or working tree
- Runs
git fetch --prune which updates remote tracking refs and removes stale ones
- Does not pull, merge, rebase, or push — use pull or push skills for those actions
Input Sanitization
- Remote name: only alphanumeric characters, hyphens, and underscores. Reject spaces,
.., shell metacharacters, or null bytes.
- Flags: only
--all accepted. Reject arbitrary strings.
/git-sync - Fetch and Show Remote Changes
Fetch the latest changes from remote without modifying your local branch. Shows what's new upstream.
Usage
/git-sync
/git-sync origin
/git-sync --all
Workflow
Step 1: Fetch Remote Changes
git fetch --all --prune
Step 2: Show Current Status
git branch --show-current
git status -sb
Step 3: Show Commits Ahead/Behind
REMOTE_BRANCH=$(git rev-parse --abbrev-ref --symbolic-full-name @{u} 2>/dev/null)
if [ -n "$REMOTE_BRANCH" ]; then
git log --oneline HEAD..$REMOTE_BRANCH
git log --oneline $REMOTE_BRANCH..HEAD
fi
Step 4: Show Changed Files Preview
git diff --stat HEAD..@{u} 2>/dev/null
Output Format
Fetched from origin, upstream
Current branch: feat/dark-mode
Tracking: origin/feat/dark-mode
Behind by 3 commits:
abc1234 Fix theme persistence
def5678 Update color palette
ghi9012 Add system theme detection
Ahead by 1 commit:
xyz7890 WIP: toggle component
Files that would change on pull:
src/theme/colors.ts | 12 ++++++------
src/hooks/useTheme.ts | 45 +++++++++++++++++++++++++++++++++++++++++++++
Next steps:
/git-pull # Pull the changes
/git-stash # Stash local changes first
Edge Cases
No Remote Tracking Branch
Branch 'feat/local-only' has no upstream tracking branch.
To set tracking:
git branch --set-upstream-to=origin/feat/local-only
Or push with tracking:
git push -u origin feat/local-only
Already Up To Date
Current branch: main
Tracking: origin/main
Already up to date.
Network Error
Failed to fetch from origin: Could not resolve host: github.com
Check your network connection and try again.
Integration
- Run
/git-pull to apply the fetched changes
- Run
/git-stash if you have uncommitted changes to save first
- Run
/git-branches to see status of all branches
Converted and distributed by TomeVault — claim your Tome and manage your conversions.