git fetch fetches information on remote branches, but does not make any changes to your local master branch. Because of this, master and origin/master are still diverged. You'd have to merge them by using git pull.

When you make a commit, your local master branch is ahead of origin/master until you push those changes. This case is the opposite, where the origin/master branch is ahead of your local master branch. This is why you are getting different outcomes.

Read https://stackoverflow.com/a/7104747/2961170 for more information.

Answer from fisk on Stack Overflow
Discussions

what does git merge origin/master do? - Stack Overflow
After fetching from remote using git fetch, we need to use something like git merge origin/master I would like to know if this command also does git commit at the same time? Is the order origin/ma... More on stackoverflow.com
🌐 stackoverflow.com
github - Is git merge origin master same as git merge origin/master? - Stack Overflow
Is git merge origin master the same as git merge origin/master. If not how is it different? the objective is to merge the latest remote master to a local branch. More on stackoverflow.com
🌐 stackoverflow.com
merge - merging (git) origin to my current local working branch - Stack Overflow
So, we have origin (remote repository) and master (local branch of that repository) ... now I work on newbranch for 2-3 days and I realize, I should refresh my newbranch since others might have added some new code (I believe, term is called "reverse integrating") ... I believe if I do git fetch origin/git merge ... More on stackoverflow.com
🌐 stackoverflow.com
git merge origin master doesn't work - Stack Overflow
git status It will get: On branch master Your branch is behind 'origin/master' by 1 commit, and can be fast-forwarded. (use "git pull" to update your local branch) nothing to commit, working tree More on stackoverflow.com
🌐 stackoverflow.com
🌐
Reddit
reddit.com › r/git › super dumb question, how to merge origin/master into my branch in one commit?
r/git on Reddit: Super dumb question, How to merge origin/master into my branch in one commit?
May 20, 2022 -

Not sure if this is the right place to ask this. My branch is behind origin master by many commits, I tried to git merge master to my branch earlier but my git log history now shows a bunch of other people’s commits, but I actually just wanted to keep my branch up-to-date with master in one commit only, something like “Merge branch ‘master’ into ‘some-branch’” any help is appreciated. Thanks

Top answer
1 of 2
28

git merge origin/master can do one of two things (or error).

In the first case, it creates a new commit that has two parents: the current HEAD, and the commit pointed to by the ref origin/master (unless you're doing something funny, this is likely to be (the local pointer to) the branch named master on a remote named origin, though this is completely conventional).

In the second case, where there is no tree-level merge necessary, rather than creating a new commit, it updates the currently checked-out ref to point to the same commit as is pointed to by origin/master. (This is called a fast-forward merge -- git can be directed to either always or never do this when you merge through command-line flags).

It does not call git commit directly, which is a higher-level (porcelain in the git-parlance) command intended for users.

Calling git merge master/original will try and resolve master/original to a commit, which will almost certainly (again, unless you've done something deliberate) not be the same as origin/master. If you happen to have a remote named master that has a branch named original, it will create a new commit which has that as the second parent.

You may find git help rev-parse to be helpful in deciphering how git attempts to resolve ref names or other notations into commits.

2 of 2
12

What this does is merges the branch referred to as origin/master into your current branch. The order is very important. The word origin means the place from which you cloned your repository, i.e., the origin of the repository, the word master is just a branch name, however master is usually used as the main branch, or the trunk branch as some other systems call it.

Merge might need to do a commit depending on the state of your development. If your history hasn't diverged from the origin, it can do what is called a fast-forward---all that needs to be done is put the new history on top of yours. If your development has diverged from the origin then if the merge can be done with no conflicts then the merge is done and a new commit is recorded at HEAD to specify the merge and the two parents.

Furthermore, if merging can't be done because of a conflict, your working copy is updated to reflect the fact that there are conflicts, then when you fix them, you manually make the commit that records the merge.

🌐
GeeksforGeeks
geeksforgeeks.org › git › git-origin-master
Git Origin Master - GeeksforGeeks
March 14, 2026 - git pull origin master fetches and merges updates from the remote master branch into the local repository.
🌐
GitHub
gist.github.com › sinewalker › 3b07efab5791bf39c05b27f103b2d391
Merge remote origin/master into a new local repository · GitHub
git remote add origin git@github.com:user/repo git fetch origin git checkout origin/master git checkout -b temp git checkout -B master temp git branch -d temp git branch --set-upstream-to=origin/master master
🌐
Why u no code?!
jporwol.wordpress.com › 2018 › 02 › 17 › what-is-origin-master-or-how-to-update-to-latest-changes-in-git
What is origin/master, or how to update to latest changes in git | Why u no code?!
February 17, 2018 - Or, if you are feeling frisky, you can try git pull origin matser – pull changes from server origin, branch master on that server, and then merge those changes into my current branch. But that’s only for the bravest!
Find elsewhere
🌐
Longair
longair.net › blog › 2009 › 04 › 16 › git-fetch-and-merge
git: fetch and merge, don’t pull – Mark's Blog
Your branch is behind the tracked remote branch 'origin/master' by 3 commits, and can be fast-forwarded. The configuration variables that allow this are called “branch.<local-branch-name>.merge” and “branch.<local-branch-name>.remote”, but you probably don’t need to worry about them. You have probably noticed that after cloning from an established remote repository git branch -r lists many remote-tracking branches, but you only have one local branch.
🌐
TutorialsPoint
tutorialspoint.com › git › git-origin-master.htm
Git - Origin Master
git merge <branch-name> − This command helps in merging the changes from another branch to master/main. In order to push the changes, the command used is git push origin mater.
🌐
LinkedIn
linkedin.com › pulse › what-differences-between-git-pull-origin-master-shruthi-rajkumar
What are the differences between "git pull", "git pull origin master", and "git pull origin/master"?
July 6, 2022 - ... Nandhini M. 3 years ago · ... master` fetches commits from the master branch of the origin remote (into the local origin/master branch), and then it merges origin/master into the branch you currently have checked out...
🌐
Git Scripts
gitscripts.com › git-merge-origin-master-into-branch
Git Merge Origin Master Into Branch: A Quick Guide
May 8, 2025 - To merge effectively, you should first fetch the latest changes from the remote repository. The command `git fetch` updates your local copy of the repository, providing you with information about new commits on the remote branches. ... This command prepares you to merge the latest changes from `origin master` into your branch.
🌐
Git
git-scm.com › docs › git-merge
Git - git-merge Documentation
Incorporates changes from the named ... changes from another repository and can be used by hand to merge changes from one branch into another. Assume the following history exists and the current branch is master:...
🌐
GeeksforGeeks
geeksforgeeks.org › git › how-to-merge-a-git-branch-into-master
How to Merge a Git Branch into Master? - GeeksforGeeks
May 22, 2024 - Start by switching to the master branch. git checkout master · Fetch and integrate the latest changes from the remote repository. git pull origin master · Switch to the branch you want to merge into master.
🌐
Git
git-scm.com › docs › git-merge-base
Git - git-merge-base Documentation
git merge-base --fork-point origin/master topic is designed to help in such a case. It takes not only B but also B0, B1, and B2 (i.e.
🌐
Togaware
togaware.com › linux › survivor › Git_Merge_Master_into.html
Git Merge Master into Branch
Notice that we could skip the first two lines and change the merge to merge origin/main to also effect a merge from the remote main into the current branch.