git fetch origin
git fetch origin main
git fetch --all
Output
remote: Counting objects: 15, done.
From https://github.com/user/project
a1b2c3d..f4e5d6c main -> origin/main
Note Fetch downloads new data but does NOT modify your working directory or merge anything. It's always safe to run. Use --all to fetch from every configured remote.
Note git pull = git fetch + git merge. Use --rebase to replay your local commits on top of the fetched changes (cleaner linear history). Some teams mandate pull --rebase to avoid unnecessary merge commits.
Frequently asked questions
How does Git handle sync remote?
Git covers this with 2 copy-ready snippets on this page. The "Fetch from Remote" snippet in Git uses `git fetch [remote] [branch]`.
Which command does the Git example use?
The "Fetch from Remote" snippet uses `git fetch [remote] [branch]`, from the Remote Repositories section of the Git cheat sheet.
What other Git snippets are shown for "sync remote"?
Besides "Fetch from Remote", this page also shows "Pull (Fetch + Merge)".
Is there anything to watch out for?
Yes. For "Fetch from Remote": Fetch downloads new data but does NOT modify your working directory or merge anything. It's always safe to run. Use --all to fetch from every configured remote.