git status
, git
reports there are modifications. However, when I do a git diff
, git
reports no difference, like the following,
$ git status .
On branch master
Your branch is up to date with 'origin/master'.
Changes not staged for commit:
(use "git add ..." to update what will be committed)
(use "git checkout -- ..." to discard changes in working directory)
modified: .gitignore
$ git diff
$
After a little bit digging, apparently a few others encountered the same problem as a Stack Overflow discussion indicates.
The cause of my case are two,
- Some files have different line endings from the version in the repository as a result that I was working on a Windows Subsystem for Linux and had the git's configuration property
core.autocrlf
set asinput
. I revealed the Windows line ending usingvim
, as in the following,
$ vim -b .gitignore # Compiled class file^M *.class^M ^M # Log file^M *.log^M ^M # BlueJ files^M *.ctxt^M
where the^M
characters are the Windows line endings, i.e.,CR LF
. I got rid of the line endings usingsed
, as in,
sed -i -e s/^M// .gitignore
Note that we enter the line ending by pressingCRTL-V CRTRL-M
- The second issue is that some files have different permissions from those in the repository. Since I was using a Windows Subsystem for Linux on a Windows host, it is difficult for me to set the permissions identical to those in the repository. However, we can let
git
to ignore permission difference, i.e.,
git config --local core.filemode false
where I only did this for the repository. If we wish to do this for globally for all repositories, just issue the command without the--local
option.
This comment has been removed by the author.
ReplyDelete