3

Git 忽略修改

 3 years ago
source link: https://blog.singee.me/2021/01/21/2d3409cd7f6f4c599d58a61673ce61cb/
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.

Git 忽略修改

发表于 2021-01-21

更新于 2021-02-01

协同工作时经常需要将一些配置文件放到仓库中,这时要保证本地的更改不会影响到远端。

一个方式是将相应文件放到 .git/info/exclude 中(语法同 .gitignore),这个文件只会在本地生效,不会上传到云端仓库

但这种方式对于已经存在的文件就无效了,如果本地编辑仓库中已经有的文件则依然会显示出更改,因此需要利用 git 的 update-index --assume-unchanged 命令将文件让 git「假装我没改过」

将以下内容加入 git config 可以简化使用

[alias]
ignore = update-index --assume-unchanged
unignore = update-index --no-assume-unchanged
ignored = !git ls-files -v | grep "^[[:lower:]]"

git ready


About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK