-2

I have a master and a dev branch. When I compare the two branches using git diff master...dev, there are no differences between them. However, when I use git diff master..dev, there are some files present in dev which are not present in master.

I'd like to merge dev into master so that those files shown by git diff master..dev (i.e files present in dev but not in master) are present in master.

When I try to create a pull request, I get "There is nothing to compare" error on github as it is using "..." for comparison. How can I merge these two based on ".." comparison?

PS: I looked at this to understand the difference between ".." and "..." but not sure how to merge with ".."

kyc12
  • 349
  • 2
  • 15
  • Sounds like you have different commits on both branches, but the files themselves are the same. Why can’t you just merge dev into master? You shouldn’t need there to be a diff to merge. – JBallin Nov 09 '20 at 23:58
  • 1
    Note that `git merge` does *not* mean "make same". It means, instead, *combine changes since some common starting point*. If the other branch has no changes since the common starting point, there is nothing to do, *even if your branch and the other branch differ*. You have changes that they don't, but adding their changes (that you already have) to your changes (that you already have) gives you back what you already have. – torek Nov 10 '20 at 00:55
  • 1
    Meanwhile, to look at it from another point of view: `git merge` never uses `..`. The two-dot vs three-dot syntax is at best a red herring—it means something different in `git diff` than it does in `git log`, and neither of them are connected directly to `git merge`. – torek Nov 10 '20 at 00:57

1 Answers1

2

git diff master...dev means git diff $(git merge-base master dev) dev.

(edit: "what @eftshift0 said":

What this means is that when you use ... you are not comparing the differences between the 2 branches you are providing.... rather, it is showing the differences between the common ancestor of those branches and the second one provided. So, on the second branch you might have committed something, then it got reverted

or there might be no commits on dev (but not already on master) at all.)

jthill
  • 55,082
  • 5
  • 77
  • 137
  • 2
    What this means is that when you use `...` you are not comparing the differences between the 2 branches you are providing.... rather, it is showing the differences between the _common ancestor_ of those branches and the second one provided. So, on the second branch you might have committed something, then it got reverted. – eftshift0 Nov 10 '20 at 00:32