Note The -v flag shows the full URLs. Without it, you only see remote names. Fetch and push URLs can differ if configured separately.
show remoteslist remotesremote urlcheck originview remote url
Fetch from Remote
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.
fetch changesdownload updatessync remoteget latest from remote
Pull (Fetch + Merge)
syntax
git pull [remote] [branch]
example
git pull origin main
# Pull with rebase instead of merge:git pull --rebase origin main
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.
pull changesget latestupdate localsync with remotedownload and merge
Push to Remote
syntax
git push [remote] [branch]
example
git push origin main
git push origin feature/payments
output
Counting objects: 5, done.
To https://github.com/user/project.git
a1b2c3d..f4e5d6c main -> main
Note Push will be rejected if the remote has commits you don't have locally. Pull first, resolve any conflicts, then push again. Avoid --force unless you truly understand the consequences (see Common Mistakes).
push changesupload commitspush to githubsend to remote
# First push of a new branch — set tracking:git push -u origin feature/payments
# After this, just use:git push
git pull
output
Branch 'feature/payments' set up to track remote branch 'feature/payments' from 'origin'.
Note The -u flag (or --set-upstream-to) links your local branch to a remote branch. After that, plain git push and git pull know where to go without specifying the remote and branch every time.
set upstreamtrack remote branchlink branch to remotepush -udefault push target
Prune Stale Remote Branches
syntax
git remote prune <remote>
git fetch --prune
example
git remote prune origin
# Or prune during fetch:git fetch --prune
Note When someone deletes a remote branch, your local reference to it lingers. Pruning removes these stale references. Does not delete your local branches — only the remote-tracking references.
prune branchesremove stale remotescleanup remote branchesdeleted remote branch still showing
Note Renaming a remote also updates all remote-tracking branches. Removing a remote deletes all its tracking branches and configuration entries.
rename remoteremove remotedelete remotechange remote name
Push All Branches
syntax
git push --all <remote>git push --tags <remote>
example
git push --all origingit push --tags origin
Note Pushes every local branch to the remote. Be cautious with this in shared repos — you might push experimental branches others don't want. --tags pushes all tags separately.
push all branchespush everythingpush tagsmirror push