GitHub Desktop: “This file is empty”

冷暖自知 提交于 2019-12-12 08:04:52

问题


The file naaclhlt2016.tex is not empty on the client or in the repository, however GitHub Desktop displays "This file is empty". What could explain this?

The file naaclhlt2016.tex is present on GitHub repository:

git status:

It creates conflict when I try to sync:


回答1:


After discussion, if the change of the tex file is only in term of metadata (and not actual file content change, after a latex recompilation), the GitHub Desktop might be unable to display any change.

Since it detects no change even though the git status list this file, it falls back to a "this file is empty" message.




回答2:


In addition to the @VonC response.

To dissmiss this alert

Git desktop

  1. unselect all changed files

  2. select only the "this file is empty" files

  3. try to commit

  4. Git will display a commit error, saying that you can't do that. After closing the modal, Git should delete the files from the changes list.




回答3:


I'm finding similar results when there is a mismatch between the autoCRLF setting (e.g. in ~/.gitconfig) and the storage of line breaks in a text file. I have .php files that were downloaded on one (Windows) machine, zipped up and unzipped in an Apache folder, then I copied those to a cloned repo and it sometimes complains about every file as changed. The files stored on GitHub seem to have been stored with CRLF (they are larger).

I have been unable to get GitHub Desktop to process my modified files. I have tried a full fresh clone with autoCRLF=true, autoCRLF=input, and autoCRLF=false, and yet GitHub Desktop either reports the files as empty or every line changed, depending on the autoCRLF setting.

I believe it is entirely because they were stored on GitHub with the CRLFs in the files, and GitHub Desktop seems to assume that the autoCRLF governs (only) the checked out files, and won't compare with CRLFs on GitHub, even with autoCRLF=false. They are byte-for-byte identical files, but they are LF-only, and it's either complaining every line has changed, or that the file is empty.

If I do a git diff on one of the files, in this case feed.php, I see: warning: CRLF will be replaced by LF in API/events/feed.php. The file will have its original line endings in your working directory.



来源:https://stackoverflow.com/questions/34559255/github-desktop-this-file-is-empty

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!