GH-REPO-SYNC(1)

πŸ’… gh-repo-sync β€” bestie, let's talk about syncing repos ✨

Okay so real talk, this is the gh repo sync era and honestly? Iconic. It's a page from the GitHub CLI manual (GitHub CLI manual, section 1, if you're keeping score πŸŽ€), and it's literally just about making one repository match another. No cap.

🌸 SYNOPSIS 🌸

gh repo sync [<destination-repository>] [flags]

πŸ¦‹ DESCRIPTION πŸ¦‹

So the whole vibe here is: you've got a destination repo and you've got a source repo, and syncing pulls the source's default branch over so that the matching branch on the destination ends up equal to it. Like, they're twins now. Matching. Periodt. πŸ’…

The default behaviour is a fast forward update β€” clean, cute, no drama. But if you specify the --force flag, then the two branches get synced using a hard reset instead. Yes girl, a hard reset. We're not asking permission anymore. πŸ”₯

If you don't give an argument at all, the local repository is selected as the destination repository. Comfy. Convenient. Lowkey the way I always do it.

And the source repository? By default it's the parent of the destination repository. But you can override that with the --source flag, iykyk. πŸ’–

✨ OPTIONS ✨

  • -b, --branch <string> β€” the branch you want to sync (default is the default branch, obviously πŸŽ€)
  • --force β€” hard resets the branch on the destination repository so it matches the source repository. The dramatic option. Use with intention, bestie πŸ’€
  • -s, --source <string> β€” the source repository 🫢

πŸ‘‘ EXIT CODES πŸ‘‘

  • 0: Successful execution β€” you ate, no crumbs πŸ“
  • 1: Error β€” something went sideways 😭
  • 2: Command canceled β€” you hit Ctrl+C or whatever, it happens πŸ™ˆ
  • 4: Authentication required β€” you need to log in, ngl
NOTE: Specific commands may have additional exit codes. Refer to the command's help for more information. ✨

🌈 EXAMPLE 🌈

Okay here's where it gets good, the actual examples, the main character moments:

# Sync local repository from remote parent
$ gh repo sync

# Sync local repository from remote parent on specific branch
$ gh repo sync --branch v1

# Sync remote fork from its parent
$ gh repo sync owner/cli-fork

# Sync remote repository from another remote repository
$ gh repo sync owner/repo --source owner2/repo2

Literally so clean. Four little commands and you're done. Obsessed. πŸ’œ

🧚 SEE ALSO 🧚

  • gh-repo(1) β€” the parent page, the mothership, go say hi 🌸

And that's the whole thing, bestie! πŸŽ€ This little gem is from the GitHub CLI, version v2.102.0, dated Oct 2026 β€” so when you're out there force-resetting branches, know that it's the GH-REPO-SYNC(1) page that taught you everything. Slay safe out there πŸ’–βœ¨πŸ¦‹

πŸ“¦ where this page comes from