use git smudge/clean to replace file contents

∥☆過路亽.° 提交于 2019-11-27 14:32:13
VonC

ideally i want the contents in the repo to be changed before i run git checkout -f not changed in the live copy after

The closest is a filter content driver which will replace the value at the git checkout.

(from Scott Schacon's Pro Git book page on Git Attributes: section "Keyword Expansion")

So in your case: a smudge filter, declared in a .gitattributes file.

See "Can git automatically switch between spaces and tabs?", except you would use a sed to replace local to live (as in this example)

I think, you have to read topic Customizing Git - Git Attributes in Git Book from start to end in order to have full picture, but especially carefully inspect part "Keyword Expansion", where custom hand-made scripts used to coverting KEYWORD in repository to FINAL TEXT in Working Directory (and in back). They are any code, which can be executed on host with Working Directory, referenced from .gitattributes file

Note: Because you have to have different clean-filter output (for local and live), you may have two slightly different (in content) clean scripts on local and live WorkingDir under common filename (in book's sample clean result in equal for all locations - single script used).

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!