title: Git file-level merge conflict caused by Git “suggesting [the file] should perhaps be moved”
body: <p>I've got a Git repo of Markdown articles, where people create pull requests (one per Markdown article) that eventually get merged to <code>master</code> and then, working directly on <code>master</code>, I move that article into a folder called <em>wordpressed</em> and commit and push to <code>master</code>.</p>
  <p>And I've got a very old pull request that is still sitting there in a branch called <code>home-base</code>, consisting of a file <em>dan/homebase.md</em> which I'm thinking of editing into shape with some more commits and then merging to <code>master</code>.</p>
  <p>This <code>home-base</code> branch is <em>so</em> old that the repo, seen from its point of view, is totally different from how it looks today in <code>master</code>. So I thought it might be good to reverse merge <code>master</code> into <code>home-base</code> just to bring it more up to date and move the merge base up a lot.</p>
  <p>But when I try to do that, I get a merge conflict that I can't understand.</p>
  <hr />
  <p>To show you the situation, I'm going to show what a <code>ls</code> of files and folders looks like in each branch. I'll start with <code>master</code>:</p>
  <pre><code>$ git status
  On branch master
  Your branch is up to date with 'origin/master'.
  nothing to commit, working tree clean
  
  $ ls -1 -R
  README.md
  dan
  instructions.md
  wordpressed
  
  ./dan:
  
  ./wordpressed:
  AppDelegateRefactor.md
  BareListContentView.md
  CellContentConfiguration.md
  ControlTargetActioniOS14.md
  GetStartedWithPods.md
  MultipleTrailingClosures.md
  StatesAndBackgrounds.md
  Swift52notes1.md
  Swift52notes2.md
  Swift52notes3.md
  UserInteractiveCells.md
  bdd-common-pitfalls.md
  bdd.md
  brantsMenuBar.md
  collectionViewContentConfig.md
  collectionViewLists.md
  collectionViewLists2.md
  collectionViewOutline.md
  debuggingLinks.md
  diffableDataSources.md
  diffableDataSources2.md
  forwardCompatibity.md
  haptics.md
  iOS13deprecations.md
  images
  inAppPurchases.md
  logging.md
  miscSwiftTricks1.md
  miscSwiftTricks2.md
  miscSwiftTricks3.md
  miscSwiftTricks4.md
  multipleSelection.md
  mysteriesOfLayout.md
  newInIOS14.md
  packages.md
  photoPicker.md
  protocolParadox.md
  splitViewControllers.md
  splitViewControllers2.md
  swiftTrickTwoClasses.md
  targetActionRant.md
  typescript-shape-of-things.md
  untappableButton.md
  what-vs-how.md
  xcode12Editing.md
  xcode12testing.md
  xcodeWhereAmI.md
  xcodeWorkInTwoPlaces.md
  
  ./wordpressed/images:
  argumentsInScheme.png
  bigFlags.png
  callHierarchy.png
  callersMenu.png
  chooser.png
  config.png
  createdTester.png
  dataOrUrl.png
  ipadportraitoverlay.png
  listOfPepBoys.png
  listWithSectionHeaders.png
  littleFlags.png
  looksLikeADuck.png
  newTester.png
  outlineIndicatorsWrong.png
  outlineIndicatorsWrong2.png
  perfectAfterHack.png
  pickAPeppa.png
  rootOnly.png
  sandboxAccountOnDevice.png
  selfSizingStringDrawer.png
  simpleList.png
  split1.png
  split2.png
  splitViewControllerPadLandscape.png
  tableViewAsChoice.png
  threecolumns.png
  twoPossibilities.png
  twoscreensphone.png
  variableRowHeights.png
  workingOutline.png
  </code></pre>
  <p>As you can see, the main folder is itself mostly empty. All the articles are in <em>wordpressed</em>, along with their images which are in <em>wordpressed/images</em>.</p>
  <hr />
  <p>Okay, now here is <code>home-base</code>:</p>
  <pre><code>$ git switch home-base
  Switched to branch 'home-base'
  Your branch is up to date with 'origin/home-base'.
  
  $ ls -1 -R
  GetStartedWithPods.md
  README.md
  Swift52notes1.md
  Swift52notes2.md
  Swift52notes3.md
  dan
  debuggingLinks.md
  images
  logging.md
  miscSwiftTricks1.md
  miscSwiftTricks2.md
  miscSwiftTricks3.md
  miscSwiftTricks4.md
  packages.md
  wordpressed
  xcode12Editing.md
  xcode12testing.md
  xcodeWhereAmI.md
  xcodeWorkInTwoPlaces.md
  
  ./dan:
  bdd.md
  homebase.md
  
  ./images:
  chooser.png
  config.png
  split1.png
  split2.png
  
  ./wordpressed:
  images
  
  ./wordpressed/images:
  </code></pre>
  <p>As you can see, that's a much earlier situation. Nothing had been moved to <em>wordpressed</em> yet. There were a few articles floating around the top level, and the <em>dan</em> folder had two articles, including the one I'm interested in here, <em>homebase.md</em>.</p>
  <hr />
  <p>Finally, for the sake of completeness, I'm going to show you the merge base between <code>master</code> and <code>home-base</code>:</p>
  <pre><code>$ git merge-base master home-base
  b5d7355fe42eddad96beb200df2cba65381c288a
  $ git checkout b5d7355fe
  $ ls -1 -R
  GetStartedWithPods.md
  README.md
  Swift52notes1.md
  Swift52notes2.md
  Swift52notes3.md
  dan
  debuggingLinks.md
  images
  logging.md
  miscSwiftTricks1.md
  miscSwiftTricks2.md
  miscSwiftTricks3.md
  miscSwiftTricks4.md
  packages.md
  wordpressed
  xcode12Editing.md
  xcode12testing.md
  xcodeWhereAmI.md
  xcodeWorkInTwoPlaces.md
  
  ./dan:
  bdd.md
  
  ./images:
  chooser.png
  config.png
  split1.png
  split2.png
  
  ./wordpressed:
  images
  
  ./wordpressed/images:
  </code></pre>
  <p>Well, it looks an awful lot like <code>home-base</code> looks now, doesn't it? The main difference is that that's before <em>homebase.md</em> appeared in the <em>dan</em> folder.</p>
  <hr />
  <p>Now then. Ask yourself, please, what should happen when I try to merge <code>master</code> into <code>home-base</code>. What are contributions from both sides of the merge? In my view, Git should realize that in <code>master</code> a lot of new files appeared in <em>wordpressed</em>, and that some of them are renames of files that used to be at the top level. Plus, of course, in <code>home-base</code>, a new file <em>homebase.md</em> has appeared in <em>dan</em>.</p>
  <p>Those contributions should not conflict (in my view).</p>
  <p>Okay, let's try it.</p>
  <pre><code>$ git switch home-base
  $ git merge master
  CONFLICT (file location): dan/homebase.md added in HEAD inside a directory that was renamed in master, suggesting it should perhaps be moved to wordpressed/homebase.md.
  Automatic merge failed; fix conflicts and then commit the result.
  
  $ git status
  On branch home-base
  Your branch is up to date with 'origin/home-base'.
  
  You have unmerged paths.
    (fix conflicts and run &quot;git commit&quot;)
    (use &quot;git merge --abort&quot; to abort the merge)
  
  Changes to be committed:
      deleted:    dan/homebase.md
      new file:   instructions.md
      new file:   wordpressed/AppDelegateRefactor.md
      new file:   wordpressed/BareListContentView.md
      new file:   wordpressed/CellContentConfiguration.md
      new file:   wordpressed/ControlTargetActioniOS14.md
      renamed:    GetStartedWithPods.md -&gt; wordpressed/GetStartedWithPods.md
      new file:   wordpressed/MultipleTrailingClosures.md
      new file:   wordpressed/StatesAndBackgrounds.md
      renamed:    Swift52notes1.md -&gt; wordpressed/Swift52notes1.md
      renamed:    Swift52notes2.md -&gt; wordpressed/Swift52notes2.md
      renamed:    Swift52notes3.md -&gt; wordpressed/Swift52notes3.md
      new file:   wordpressed/UserInteractiveCells.md
      new file:   wordpressed/bdd-common-pitfalls.md
      renamed:    dan/bdd.md -&gt; wordpressed/bdd.md
      new file:   wordpressed/brantsMenuBar.md
      new file:   wordpressed/collectionViewContentConfig.md
      new file:   wordpressed/collectionViewLists.md
      new file:   wordpressed/collectionViewLists2.md
      new file:   wordpressed/collectionViewOutline.md
      renamed:    debuggingLinks.md -&gt; wordpressed/debuggingLinks.md
      new file:   wordpressed/diffableDataSources.md
      new file:   wordpressed/diffableDataSources2.md
      new file:   wordpressed/forwardCompatibity.md
      new file:   wordpressed/haptics.md
      new file:   wordpressed/iOS13deprecations.md
      new file:   wordpressed/images/argumentsInScheme.png
      new file:   wordpressed/images/bigFlags.png
      new file:   wordpressed/images/callHierarchy.png
      new file:   wordpressed/images/callersMenu.png
      renamed:    images/chooser.png -&gt; wordpressed/images/chooser.png
      renamed:    images/config.png -&gt; wordpressed/images/config.png
      new file:   wordpressed/images/createdTester.png
      new file:   wordpressed/images/dataOrUrl.png
      new file:   wordpressed/images/ipadportraitoverlay.png
      new file:   wordpressed/images/listOfPepBoys.png
      new file:   wordpressed/images/listWithSectionHeaders.png
      new file:   wordpressed/images/littleFlags.png
      new file:   wordpressed/images/looksLikeADuck.png
      new file:   wordpressed/images/newTester.png
      new file:   wordpressed/images/outlineIndicatorsWrong.png
      new file:   wordpressed/images/outlineIndicatorsWrong2.png
      new file:   wordpressed/images/perfectAfterHack.png
      new file:   wordpressed/images/pickAPeppa.png
      new file:   wordpressed/images/rootOnly.png
      new file:   wordpressed/images/sandboxAccountOnDevice.png
      new file:   wordpressed/images/selfSizingStringDrawer.png
      new file:   wordpressed/images/simpleList.png
      renamed:    images/split1.png -&gt; wordpressed/images/split1.png
      renamed:    images/split2.png -&gt; wordpressed/images/split2.png
      new file:   wordpressed/images/splitViewControllerPadLandscape.png
      new file:   wordpressed/images/tableViewAsChoice.png
      new file:   wordpressed/images/threecolumns.png
      new file:   wordpressed/images/twoPossibilities.png
      new file:   wordpressed/images/twoscreensphone.png
      new file:   wordpressed/images/variableRowHeights.png
      new file:   wordpressed/images/workingOutline.png
      new file:   wordpressed/inAppPurchases.md
      renamed:    logging.md -&gt; wordpressed/logging.md
      renamed:    miscSwiftTricks1.md -&gt; wordpressed/miscSwiftTricks1.md
      renamed:    miscSwiftTricks2.md -&gt; wordpressed/miscSwiftTricks2.md
      renamed:    miscSwiftTricks3.md -&gt; wordpressed/miscSwiftTricks3.md
      renamed:    miscSwiftTricks4.md -&gt; wordpressed/miscSwiftTricks4.md
      new file:   wordpressed/multipleSelection.md
      new file:   wordpressed/mysteriesOfLayout.md
      new file:   wordpressed/newInIOS14.md
      renamed:    packages.md -&gt; wordpressed/packages.md
      new file:   wordpressed/photoPicker.md
      new file:   wordpressed/protocolParadox.md
      new file:   wordpressed/splitViewControllers.md
      new file:   wordpressed/splitViewControllers2.md
      new file:   wordpressed/swiftTrickTwoClasses.md
      new file:   wordpressed/targetActionRant.md
      new file:   wordpressed/typescript-shape-of-things.md
      new file:   wordpressed/untappableButton.md
      new file:   wordpressed/what-vs-how.md
      renamed:    xcode12Editing.md -&gt; wordpressed/xcode12Editing.md
      renamed:    xcode12testing.md -&gt; wordpressed/xcode12testing.md
      renamed:    xcodeWhereAmI.md -&gt; wordpressed/xcodeWhereAmI.md
      renamed:    xcodeWorkInTwoPlaces.md -&gt; wordpressed/xcodeWorkInTwoPlaces.md
  
  Unmerged paths:
    (use &quot;git add &lt;file&gt;...&quot; to mark resolution)
      added by us:     wordpressed/homebase.md 
  </code></pre>
  <hr />
  <p>Okay, so that last line is the one I don't understand. What does it mean to say that &quot;added by us&quot; is <em>wordpressed/homebase.md</em>? <em>NO!</em> That's not where we added it. We added it in <em>dan</em>.</p>
  <p>Neither <code>master</code> nor <code>home-base</code> has a file <em>wordpressed/homebase.md</em>. So where is Git getting the idea that there is one??? It seems to have something to do with the same reason why it thinks there is a merge conflict at all:</p>
  <blockquote>
  <p><em>dan/homebase.md</em> added in HEAD inside a directory that was renamed in master, suggesting it should perhaps be moved to wordpressed/homebase.md.</p>
  </blockquote>
  <p>So: <em>What is Git talking about here?</em> Why does Git think that <em>dan/homebase.md</em> should be <em>wordpressed/homebase.md</em>, on no evidence whatever that I can find? How can I prevent this merge conflict and get Git to be more simplistic about this? Could I perhaps use a different merge strategy? Or how can I simply resolve the conflict in such a way as to say, No, Git, just leave <em>dan/homebase.md</em> alone, please?</p>
  <p>Again, apologies for the length of the detail in the question.</p>