Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

"Will not add file alias 'samefile' ('SameFile' already exists in index)" when `git add` operation

Tags:

git

I download linux' kernel source, and want to git add them all.

When I git add ., git starts add them. But soon it returns an error:

fatal: Will not add file alias 'include/linux/netfilter/xt_connmark.h' ('include/linux/netfilter/xt_CONNMARK.h' already exists in index)

That's weird, xt_connmark.h and xt_CONNMARK.h are TOTALLY DIFFERENT, why it complains that error? Those situations occur at other folders, too. I can't just change their names separately to solve this problem.

Even I try git add --ignore-errors ., it doesn't works,too. It just stopped without ignoring this error. Anyone knows solutions?

like image 932
naive231 Avatar asked Aug 30 '14 08:08

naive231


3 Answers

Edit .git/config to set ignorecase to false

[core]
  ignorecase = false

Can be set globally

$ git config --global core.ignorecase false
like image 95
Interlated Avatar answered Nov 05 '22 10:11

Interlated


Use

git rm --cached <file>

This will completely remove the file's contents from the index but leaves it in the working directory. On commit, the files will be removed from the HEAD commit.

I would recommend to backup your project before doing that.

like image 28
Syyam Noor Avatar answered Nov 05 '22 10:11

Syyam Noor


Actually, I made such type of error by my ownself mistake.

firstly, I created file name with Small letters, later I changed file name in the capital letters which is git not tracking

  1. Change the capitalization of the "file" name and add "1" to the end (or another symbol) Stage (without commit) = result "File1" - renaming files***
  2. Remove "1" from the end Stage (without commit) = result "File" - renaming files (only capitalization now)
  3. Now Do commit.

or try this

$ git config --local core.ignorecase false 

Reference

like image 41
Santosh Kumar Avatar answered Nov 05 '22 10:11

Santosh Kumar