git fetch downloads the latest commits and branches from the remote and updates your remote-tracking branches (such as origin/main). It does not touch your working files or your current branch. It is always safe.
git pull is git fetch followed by a merge (or a rebase, if configured) into your current branch. It changes your files.
Using fetch first lets you look before you leap:
git fetch
git log HEAD..origin/main --oneline # what is new on the remote?
git diff HEAD origin/main # what exactly changed?
Then merge or rebase when you are ready.
If you like the shortcut but want a clean history, you can run git pull --rebase, or set it as the default with git config pull.rebase true. For small personal projects, plain git pull is fine.
Markdown for AI
A clean, structured version of this page for AI assistants and LLMs.
We use cookies to ensure you have the best browsing experience on our website. By using our site, you
acknowledge that you have read and understood our
Cookie Policy &
Privacy Policy.
git fetchfollowed by a merge (or a rebase, if configured) into your current branch. It changes your files.Using fetch first lets you look before you leap:
Then merge or rebase when you are ready.
If you like the shortcut but want a clean history, you can run
git pull --rebase, or set it as the default withgit config pull.rebase true. For small personal projects, plaingit pullis fine.