fix git diff-files listing all files in docker

给你一囗甜甜゛ 提交于 2019-12-06 03:59:14

git diff-files uses a hashing algorithm to compare files in the working tree and the index. The files in the working tree have the same hashes as the ones in a local environment.

My hypothesis is that when you run git diff-files in the docker container, the index wasn't reflected properly due to the docker volume mount and hence the output. This does not happen if you were to re-clone the entire repository in the docker container itself. However, if you switch context back to your local environment right after this and do git diff-files, the behavior is reversed (i.e. it lists all the files when you are outside the container, but not inside the container).

Here's what you can do since you might be switching between the docker container and your local environment:

git diff > /dev/null && git diff-files

Use git diff to refresh the index and force the output to /dev/null, then git diff-files will reflect the right output. You need to do this in both environments, especially when switching from one to another. If you feel that the whole command is too long, you might find git aliases to be helpful.

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