只需告訴混帳假設該文件是不變的:
$ git update-index --assume-unchanged FILE [FILE ...]
從手冊:
--assume-unchanged, --no-assume-unchanged
When these flags are specified, the object names recorded for the paths are not updated. Instead, these options set and unset the "assume unchanged" bit for the paths. When the "assume unchanged" bit is on, git stops checking the
working tree files for possible modifications, so you need to manually unset the bit to tell git when you change the working tree file. This is sometimes helpful when working with a big project on a filesystem that has very slow
lstat(2) system call (e.g. cifs).
This option can be also used as a coarse file-level mechanism to ignore uncommitted changes in tracked files (akin to what .gitignore does for untracked files). Git will fail (gracefully) in case it needs to modify this file in the
index e.g. when merging in a commit; thus, in case the assumed-untracked file is changed upstream, you will need to handle the situation manually.
在How to Ignore Changes in Tracked Files With Git
完美的存在!這解決了我的問題。我在.git/info/attributes中添加了「.htaccess filter = htaccess」,然後在.git/config中加入: [filter「htaccess」] clean = sed's |/mypath |/dev' smudge = sed's |/dev |/mypath' 現在,任何對.htaccess文件中的/ dev/something的引用都會被/ mypath/something替換,並在末尾恢復,這意味着我甚至可以編輯該文件並提交我的更改沒有在回購中獲得/ mypath版本! – Malvineous 2010-04-21 01:37:46