3

Note the lack of a "/" in the command.

I am a git novice.

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

git push origin branchname

On test-machine, I did:

git fetch origin 
git merge origin branchname

Git reported "Already up-to-date. Yeeah!" But I knew I wasn't.

Eventually I did the correct

git merge origin/branchname 

What happened when I screwed up and did:

git merge origin branchname 

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

David Poole
  • 3,432
  • 5
  • 34
  • 34
  • Yup. Duplicate. I voted to close my question. Should I delete it instead? – David Poole Sep 04 '14 at 19:58
  • 1
    You won't be able to delete your question now that answers to it have been posted. Anyway, duplicates are not all bad; they help people (who may not all use the same search query) converge to a solution to their problem. – jub0bs Sep 04 '14 at 19:59

2 Answers2

4

It means "merge the branches origin and branchname into the current branch" -- effectively requesting that two other branches be merged into your current branch. Note that origin is a remote; when used as a commit identifier, it is equivalent to origin/HEAD (which typically points to origin/master).

So, assuming that you had branchname checked out already, you were attempting to merge the branch with itself, and this is a no-op. It sounds like origin/HEAD was already "merged" (the commit is an ancestor of branchname) so that also was also resolved as a no-op.

In other words, both commits you tried to merge into your branch were already part of your branch history, so Git correctly didn't do anything.

cdhowie
  • 158,093
  • 24
  • 286
  • 300
  • Using the term "[three-way merge](http://en.wikipedia.org/wiki/Merge_(revision_control)#Three-way_merge)" in this context has the potential to confuse. You should instead write "the merge of two branches into another" or something like that. – jub0bs Sep 04 '14 at 19:24
  • 1
    @Jubobs Fair point, sometimes I forget that three-way merge generally refers to how files are merged. It's not an inaccurate term in this context but could be misleading based on how the term is usually used, and I understand that. – cdhowie Sep 04 '14 at 19:26
  • One oddity that may be worth mentioning in your answer is that the default commit message suggested by Git after `git merge origin` is `Merge remote-tracking branch 'origin'`, which is misleading. – jub0bs Sep 04 '14 at 19:34
-2

When you have branchname on a remote origin, then on your local you call origin/brachname, that is you make a local copy of branch on the remote. origin/brachname is a branch.

So what you did was fetch the branch (branchname) from the remote (origin). Now you have a local copy (origin/branchname) which you then merge into your local branch (branchname).

sis
  • 142
  • 13
  • This appears to restate information the OP already knows, but does not address the particular form of Git command (`git merge origin branchname`) that OP does not understand. As such, it does not actually answer the question at all. – cdhowie Sep 04 '14 at 19:29