0

I was able to add my directory to git and do a git commit but strangely, when I am doing

$ git add .

I am getting the following error:

warning: LF will be replaced by CRLF in .idea/workspace.xml.
The file will have its original line endings in your working directory.
warning: LF will be replaced by CRLF in grails-app/controllers/com/abc/pqr/Rep
ortController.groovy.
The file will have its original line endings in your working directory.
warning: LF will be replaced by CRLF in grails-app/domain/com/abc/pqr/Report.g
roovy.
The file will have its original line endings in your working directory.
fatal: unable to stat 'Dirname#com.abc.pqr.Report': No such file or directo
ry

I have already gone through this SO answer and if I try:

$ git rm Dirname#com.abc.pqr.Report

I get this error:

fatal: pathspec 'Dirname#com.abc.pqr.Report' did not match any files

Surprisingly there is no file as on searching through above directory, I do not find any such file as described above.

It is worth mentioning that there was a file Dirname/#com.abc.pqr.Report in the root directory(i.e. file #com.abc.pqr.Report under Dirname under the root directory). Which I was strangely not able to delete, an issue similar to this(I am using windows-7 os) and I could resolve it using this.But ever since I (accidentaly through a buggy grails script) created the above file, I have not been able to do the `git add .

Community
  • 1
  • 1
rahulserver
  • 10,411
  • 24
  • 90
  • 164

2 Answers2

1

If you do not want Dirname#com.abc.pqr.Report to be part of your commit, stage the changes you do want explicitly. For example:

$ git add .idea/workspace.xml
$ git add grails-app/controllers grails-app/domain
...

The commands above assume that Dirname#com.abc.pqr.Report was not in one of the named directories. If it was, then name toplevel directories where you can and be specific when forced.

Once you have staged all the changes you want with git add, you can safely commit them with git commit.

Greg Bacon
  • 134,834
  • 32
  • 188
  • 245
  • It seems to be the answer But from now on, I need to add each directory separately.So say i am modifying 100 different files in 10 different files, then I would have to do 10 git adds, which is very tedious.In short I would not be able to do "git add ." again. I am looking to get rid of this "dangling symlink" permanently – rahulserver Aug 13 '13 at 19:47
  • The above is a workaround. The fix is to figure out how to remove that file. – Greg Bacon Aug 13 '13 at 19:49
  • Since your answer works, and anyways i have been able to atleast push my current commit so I upvote for your answer.But still I would await to get the final solution. – rahulserver Aug 13 '13 at 19:50
1

In Unix systems the end of a line is represented with a line feed: LF. In windows a line is represented with a carriage return: CR and a line feed: LF(CRLF). So if you are trying to added files from linux then it has only LF, as a result warning showing. It's nothing to worry about. Anyways I think git add . command will add your files. Just do a git status and verify it's added.

Deepak Biswal
  • 4,280
  • 2
  • 20
  • 37
  • "Anyways I think git add . command will add your files." no it does not as Its not getting committed and shows me "no changes added to commit (use "git add" and/or "git commit -a")" – rahulserver Aug 13 '13 at 19:53
  • Hmm. I'll check and let you know. BTW try `$ git rm Dirname#com.abc.pqr.Report` with proper file path. I don't think this is correct `Dirname#com.abc.pqr.Report`. – Deepak Biswal Aug 13 '13 at 20:00
  • I have no way to get to the file as I have deleted the whole structure. Initially there was #com.abc.pqr.Report in a directory Dirname which was inside the root directory(.).I deleted the whole Dirname directory with its contents. So is it not a bug in git that due to just error in one file, its not adding any of the files to be tracked? – rahulserver Aug 14 '13 at 03:05