Note that there are some explanatory texts on larger screens.

plurals
  1. POOn OSX, git merge deletes file with renamed capitalization
    text
    copied!<p>I wrote this script and ran it on OSX 10.8 Mountain Lion, on the default case-insensitive HFS filesystem.</p> <pre><code>#!/bin/sh -x # create git repo rm -rf caps git init caps cd caps # commit empty file called "file" touch file git add . git commit -am "initial commit" # create branch called "branch" git branch branch # rename "file" to "File" # using --force per http://stackoverflow.com/questions/6899582 git mv --force file File git commit -am "renamed capital" # switch to branch, make a non-conflicting commit git checkout branch touch newfile git add . git commit -am "branch commit" # merge master into branch, commit merge git merge --commit --no-edit master # but where's the renamed File? more File </code></pre> <p>When the script was done, it failed on the last line, when it should have succeeded:</p> <pre><code>+ git merge --commit --no-edit master Removing file Merge made by the 'recursive' strategy. file =&gt; File | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename file =&gt; File (100%) + more File File: No such file or directory </code></pre> <p>git status showed this:</p> <pre><code>$ git status # On branch branch # Changes not staged for commit: # (use "git add/rm &lt;file&gt;..." to update what will be committed) # (use "git checkout -- &lt;file&gt;..." to discard changes in working directory) # # deleted: File # no changes added to commit (use "git add" and/or "git commit -a") </code></pre> <p>We can get the file back at that point with <code>git checkout File</code>, but it's very easy at that point to accidentally commit the deletion.</p> <p>We've been renaming quite a few files lately, fixing their capitalization, and this has bit our team a lot. Is there a git setting or best practice we can use to workaround this problem? (For now, we're just telling everybody to be extra extra careful.)</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload