git fetch
Downloads objects and refs from a remote repository without merging.
Syntax
git fetch [<options>] [<remote>] [<refspec>...]
Options
- --all: Fetches from all remotes
- --prune: Removes remote-tracking references that no longer exist on the remote
- --tags: Fetches all tags from the remote
- --depth <depth>: Limits the number of commits fetched
- --dry-run: Shows what would be fetched without actually fetching
Example
git fetch origin git fetch --all git fetch origin main git fetch --prune
Tip
Use --prune regularly to clean up stale remote-tracking branches.