views:

187

answers:

3

While I found similar question I didn't find an answer to my problem

When I try to rename the directory from FOO to foo via git mv FOO foo I get

fatal: renaming 'FOO' failed: Invalid argument

OK. So I try git mv FOO foo2 && git mv foo2 foo

But when I try to commit via git commit . I get

# On branch master
# Untracked files:
#   (use "git add <file>..." to include in what will be committed)
#
# foo
nothing added to commit but untracked files present (use "git add" to track)

When I add the directory via git add foo nothing changes and git commit . gives me the same message again.

What am I doing wrong? I thought I'm using a case-sensitive system (OSX) why can't I simply rename the directory?

A: 

You're not using a case-sensitive filesystem in OS X unless you explicitly choose such. HFS+ can be case-sensitive, but the default is case-insensitive.

Nicholas Knight
A: 

You want to set the option core.ignorecase to false, which will make Git pay attention to case on file systems that don't natively support it. To enable in your repo:

$ git config core.ignorecase false

Then you can rename the file with git mv and it'll work as expected.

mipadi
I think this may have undesirable effects elsewhere. Case insensitive systems should let Git think that it's the same dir.
adymitruk
@mipadi I added the option to my global config but it didn't help
oschrenk
On OS X? It worked for me.
mipadi
+5  A: 

You are not in a case insensitive environment. Further, adding with out the -A will not take care of the remove side of the mv as Git understands it. To get around this, do the following to trick your OS:

mv foo foo2
git add -A .
git commit -m "renaming"
mv foo2 FOO
git add -A .
git commit --amend -m "renamed foo to FOO"

HTH,

Adam

adymitruk
@adymitruk Thanks. This was driving me crazy. I didn't know about the -A or the --amend option.
oschrenk