I’ve performed some behavior testing on assume-unchanged and skip-worktree flags and here are the findings:
I haven’t looked into the performance boost yet.
ANALYSIS
It looks like skip-worktree is trying very hard to preserve your local data. But it doesn’t prevent you to get upstream changes if it is safe. Plus git doesn’t reset the flag on pull. But ignoring the ‘reset --hard’ command could become a nasty surprise for a developer.
Assume-unchanged flag could be lost on the pull operation and the local changes inside such files doesn’t seem to be important to git.
Both of the statements above are in correspondence with git mail archive:
http://thread.gmane.org/gmane.comp.version-control.git/146082 - Junio’s (current git maintainer) comment regarding intent of assume-unchanged.
http://osdir.com/ml/git/2009-12/msg01123.html - difference between assume-unchanged and skip-worktree as discussed in git mailing list upon addition of skip-worktree patch.
Actually neither of the flags is intuitive enough. Assume-unchanged assumes that a developer shouldn’t change a file. If a file was changed – than that change is not important. This flag is meant for improving performance for not-changing folders like SDKs. But if the promise is broken and a file is actually changed, git reverts the flag to reflect the reality. Probably it’s ok to have some inconsistent flags in generally not-meant-to-be-changed folders. On the other hand skip-worktree is useful when you instruct git not to touch a specific file ever. That is useful for an already tracked config file. Upstream main repository hosts some production-ready config but you would like to change some settings in the config to be able to do some local testing. And you don’t want to accidentally check the changes in such file to affect the production config. In that case skip-worktree makes perfect scene.
- .gitignore:这个忽略文件会上传到远程仓库,会使所有人都按照这个文件规则忽略文件
- .git/info/exclude:这个会删除远程仓库忽略文件,保留本地文件
- assume-unchanged:这个会关闭文件与远程仓库的跟踪,认为这个文件远程仓库是不会修改,所以每次pull都是本地的文件
- skip-worktree:这个不会关闭文件与远程仓库的跟踪,只是告诉Git不要跟踪对本地文件/文件夹的更改,每次pull时会拉取最新的变化会提示冲突,但因为没有跟踪本地更改,所以需要no-skip-worktree再合并最新的变化
以上在commit时都会忽略文件