git - GIT 使用文件修改数据而不是文件内容
问题描述
我很好奇 git 是否可以检查实际文件而不是文件修改日期/时间。Git 目前只检查文件修改时间,即使文件内容相同,它也会显示为已修改。我们可以改变这种行为吗?
解决方案
git
当然不会这样。它检查文件修改日期,如果没有更改,则git
决定文件没有被修改。但是,如果修改日期改变git
并不能决定文件是否被修改——它会检查内容。看:
$ git init test-git
Initialized empty Git repository in tmp/test-git/.git/
$ cd test-git/
$ echo >test.txt
$ git add test.txt
$ git commit -m "Initial commit"
[master (root-commit) c02d9aa] Initial commit
1 file changed, 1 insertion(+)
create mode 100644 test.txt
$ git status
On branch master
nothing to commit, working tree clean
$ touch test.txt
$ git status
On branch master
nothing to commit, working tree clean
touch
更改文件时间戳但git
仍认为文件未更改,因为它检查了内容并发现它相同。
推荐阅读
- firebase - 如何匹配 Flutter Firestore 查询和 Firestore 安全规则?
- java - 客户端向 API 服务器发送完整数据所用的时间
- flutter - 如何让flutter应用的高宽适应不同的屏幕尺寸?
- svg - ThreeJS:如何加载其中包含文本的 SVG 文件
- python - django post请求中的JSON解析错误
- python-3.x - Pycharm IDE 破坏了 pip
- apache-spark - 更改增量表中列的数据类型
- java - 如何在 bean 中为 spring mvc 添加 jpa 存储库?
- css - 破折号情节/ CSS。下拉菜单中所选选项的字体颜色
- matplotlib - 为什么我的实时 matplotlib 图形是空白的?