0

I'm completely confused as to why this procedure is not working and would very much appreciate some help. I'm confident this same procedure worked last week.

  1. git clone
  2. copy files from outside of the repo into the cloned repo (all of which have the same name as files already in the repo)
  3. 'git status' shows a whole bunch of modified files. Great
  4. 'git add .'
  5. 'git status' shows working directory clean, nothing to commit.

Why?

Jay
  • 456
  • 4
  • 11
  • 1
    You say the copied files have the same names as already existing files, so you are basically overwriting them. But do they actually also have changes (besides probably line endings format)? – dunni Jun 20 '22 at 10:58
  • are you in a specific branch? – Suraj Rao Jun 20 '22 at 11:04
  • I don't know whether they actually have changes (besides the line endings) because I'm not the one changing them. When git says that the files are modified I take it that they have been changed. So you mean to tell me they might not contain any changes at all and git is only saying they are modified because of line endings?? – Jay Jun 20 '22 at 11:04
  • @dunni it seems so since OP says it showed modifications before "git add ." – Suraj Rao Jun 20 '22 at 11:05
  • 1
    Yes, and depending on your configurations regarding line endings, it could be that Git recognizes the line endings, but as soon as you stage the commit, it converts them and thus the file contents are now equal to what is already committed (note, this is only suspicion on my side) – dunni Jun 20 '22 at 11:06
  • Why not use git diff to find out? It seems silly to guess. – matt Jun 20 '22 at 11:07
  • You can try again and run `git diff` to check what changes there are. – dunni Jun 20 '22 at 11:07
  • @dunni fml, I'll have a look.. there definitely should be some changes other than line endings but it's an assumption on my part for now – Jay Jun 20 '22 at 11:07
  • @matt you are right, but you have to appreciate that in my mind 'git status' is checking since that is somewhat the remit of that command – Jay Jun 20 '22 at 11:33
  • Not exactly. When Git status says there _are_ modified files, Git diff will tell you _what_ the modifications are. And that is exactly what you want to know. – matt Jun 20 '22 at 11:40
  • So, 'git diff' says 'warning: LF will be replaced by CRLF \n The file will have its original line endings in your working directory' and it says that seemingly for every file. So from that we can conclude that there are no changes (that I actually care about) to any of the files? – Jay Jun 20 '22 at 11:42
  • If you don't care about Git messing with your line endings, sure. Personally I'd be quite concerned about that. – matt Jun 20 '22 at 11:49
  • Isn't git just auto converting based on the OS that the repo is cloned onto? – Jay Jun 20 '22 at 13:28
  • 1
    You might want to read https://stackoverflow.com/questions/3206843/how-line-ending-conversions-work-with-git-core-autocrlf-between-different-operat – matt Jun 20 '22 at 13:38

1 Answers1

0

Try first in your cloned repository git ls-files --eol (Git 2.8 (March 2016))

Try also the same clone after git config --global core.autocrlf false.

If this is eol (end-of-line) related, there should be no diff, and git status should be clean.

VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250