The command:
git merge foo
says to merge into the currently checked out branch the local branch called foo
. By "local," I mean the local version of the foo
branch on which you might have been doing your work.
The command:
git merge origin/foo
says to merge into the currently checked out branch the remote tracking branch called origin/foo
. foo
and origin/foo
might be pointing to the same commit, or they might not. For example, if you have recently fetched, then it's possible (or even likely) that origin/foo
would be more recent than the local foo
you have on your machine.
By the way, if you're wondering what the utility of the remote tracking branches is, these branches are local branches on your machine which exist as proxies for the true remote branches in the repository. Git operations primarily operate locally, and this distributed support is one reason which makes Git powerful.
For added information, suppose you wanted to push your local foo
branch to the remote, via:
git push origin foo
In this case, origin
actually refers to the remote Git repository (e.g. something like GitHub or Bitbucket), and foo
refers to the local branch you want to push.