git fetch

At it’s most basic, the purpose of git fetch is to “fetch” all the available commits (and tags, by default) from a remote (read: another instance of your git repo somewhere else) into your local git repo, so that you can check them out, compare to them, rebase them, etc.

Note that – unlike git pullgit fetch does not modify the tracked files in your local repo, nor to your locally checked-out branch. It merely makes use of the network or file system to obtain the latest commits from a remote so that you make use of them.

In other words, after you run this, you’ll still be in the same situation you were before with your staged/unstaged changes, and with the commit you’re working on top of.

What about git pull?

tl;dr: avoid the use of git pull

By default, the sometimes popular command git pull is the equivalent of something like (depending on origin name and current branch name):

git fetch origin && git merge origin/master

Generally I recommend avoiding the use of git pull because in many cases when you want to get access to changes from a remote you don’t simultaneously want to do a merge.