git的--skip-worktree

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时都会忽略文件

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

SHUIPING_YANG

你的鼓励是我创作的最大动力。

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值