Sync remote

2 snippets in Git

Also written as sync with remote

GitGit

Fetch from Remote

Git · Remote Repositories
syntax
git fetch [remote] [branch]
example
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.

Pull (Fetch + Merge)

Git · Remote Repositories
syntax
git pull [remote] [branch]
example
git pull origin main

# Pull with rebase instead of merge:
git pull --rebase origin main
output
Updating a1b2c3d..f4e5d6c
Fast-forward
 src/app.js | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

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.