Skip to content
Log In Sign Up info@muvcloud.com

The Difference at a Glance

git fetchgit pull
Downloads commitsYesYes
Changes your branchNoYes
Changes your filesNoYes
Can cause conflictsNoYes

What git fetch Does

git fetch origin

Fetch updates the remote-tracking branches, such as origin/main, which are your clone's copy of the remote's state. Your own main stays where it was. That makes fetch safe to run at any time.

See what arrived before you use it:

git log --oneline HEAD..origin/main
git diff --stat HEAD origin/main

The first command lists commits on the remote that your branch lacks; the second lists the files they change.

Fetch, Then Merge

When the changes look right, bring them in:

git merge origin/main

Together, git fetch and git merge are what git pull does in one step.

What git pull Does

git pull

Pull fetches the branch your current branch tracks and merges it. If you have no local commits, the merge is a fast-forward: your branch moves forward and no merge commit is made. If both sides have new commits, the branches have diverged, and Git must combine them.

Current Git versions do not merge diverged branches on their own when no method is configured: the pull stops with an error and suggests the options. Pick one of the options below once, globally.

pull --rebase and --ff-only

  • git pull --rebase: replays your local commits on top of the remote ones. History stays in one line. Set it as the default with git config --global pull.rebase true.
  • git pull --ff-only: updates only if a fast-forward is possible and otherwise stops without changing anything. Set it with git config --global pull.ff only.

Rebase rewrites your local commits, so use it only for commits you have not pushed yet.

Handling Conflicts

If the same lines changed on both sides, Git stops and marks the files. Then:

  1. Run git status to see the conflicted files.
  2. Edit each file, choose the right lines, and remove the conflict markers.
  3. Run git add on each fixed file.
  4. Finish with git commit after a merge, or git rebase --continue after a rebase.

To give up and return to where you were, run git merge --abort or git rebase --abort.

Which to Use on a Server Checkout

A deployment folder should never hold its own commits or edits. Update it in this order, as the user that owns the files:

git status
git fetch origin
git log --oneline HEAD..origin/main
git pull --ff-only

If git status shows local changes, find out who made them before you continue. Put them aside with git stash rather than discarding them. If --ff-only refuses, the checkout has commits the remote lacks; inspect them with git log --oneline origin/main..HEAD before you decide anything. Resetting the folder to the remote is covered, with its warnings, in git reset explained.

Common Problems

  • Your local changes would be overwritten: commit or stash the listed files, then pull again.
  • No tracking information: set the upstream with git branch -u origin/main.
  • Authentication fails: check the address with git remote -v; see how to change a Git remote URL and SSH keys with GitHub.

Updated:

Linux VPS with Full Root Access

MUVCloud cloud servers run on KVM with Enterprise NVMe SSD storage and full root access, in Turkey, the Netherlands, and the USA.

Cloud VPS Plans Starting at2.99 $/mo Cheap Linux VPS

No Limits on Service or Support

You are not on your own as your projects grow. Our support engineers are ready 24/7, on several channels, whenever you need them.

Support specialist
  • 100% customer satisfaction goal
  • Our own hardware
  • 24/7 ticket and email support
  • 4 countries with locations