What does git merge origin branchname do?

Note the absence of "/" in the command.

I'm a git newbie.

I am working on the same codebase, one branch, on two separate machines (one dev machine, one test machine). I pushed the code to dev-machine.

git push origin branchname

      

On a test machine, I did:

git fetch origin 
git merge origin branchname

      

Git reported, "Already updated. Yeeah!" But I knew it wasn't.

In the end I did the right one

git merge origin/branchname 

      

What happened when I messed up and did:

git merge origin branchname 

      

http://git-scm.com/docs/git-merge mentions "octopus merge" but "origin" is special (not branch name) so I don't think what happened.

+3


source to share


2 answers


It means "to unite the branch origin

and branchname

in the current branch" - effectively seek the union of two other branches in your current branch. Please note that origin

is remote; when used as a commit identifier, it is equivalent to origin/HEAD

(which usually points to origin/master

).



So, if you've already checked branchname

, you've tried to merge the branch with itself, and that's a non-op. It looks like it was origin/HEAD

already "merged" (the commit is an ancestor branchname

), so it was also resolved as a no-op.

In other words, both commits you were trying to merge into your branch were already part of your branch history, so Git did nothing.
+3


source


If you have a branchname on a remote origin, then in your local language you call origin / brachname, meaning you make a local copy of the branch on the remote. origin / brachname is a branch.



So you've made a branch selection (branchname) from the remote (origin). You now have a local copy (origin / branchname), which you then merge into your local branch (branchname).

-2


source







All Articles