滤除git commit上JSON文件的某些部分
我希望过滤JSON文件的特定部分,以使文件的给定部分不会被拉到git存储库中。我的用例是,我正在设置一个存储库来保留一些工作文件,包括VSCODE的设置。我有一个用于窗口颜色的插件,可以为开放的不同窗口设置不同的颜色。当前颜色保存在该窗口的.vscode/street.json文件中。
我发现可以在哪里使用.gitAttributes文件将过滤器应用于文件或一组文件,然后使用“ $ git config”从所承诺的内容中删除某些行,基于sed命令per 此之前的问题 。
我想将其应用于以下JSON文件中的“ workbench.colorcustomization”对象,以便该对象不会被投入,而可以使用文件中的其他设置,例如“ editor.formatonpaste”对象。有人知道这样做的方法吗?
{
"workbench.colorCustomizations": {
"activityBar.background": "#102D56",
"titleBar.activeBackground": "#173F79",
"titleBar.activeForeground": "#F8FAFE"
},
"editor.formatOnPaste": true
}
I am looking to filter out specific parts of a json file so that the given part of the file does not get pulled into a git repository. My use case is that I am setting up a repository to keep some working files, including settings for vsCode. I have a plugin for window colors that sets different colors for different windows that are open. The current color is saved in the .vscode/setting.json file for that window.
I found where it is possible to use the .gitattributes file to apply a filter to a file or set of files, and then use "$git config" to remove certain lines from what is committed, based on a sed command per this previous question.
I would like to apply this to the "workbench.colorCustomizations" object within the following json file, so that this object does not get committed, while other settings in the file may be committed, such as the "editor.formatOnPaste" object. Does anyone know of a way to do this?
{
"workbench.colorCustomizations": {
"activityBar.background": "#102D56",
"titleBar.activeBackground": "#173F79",
"titleBar.activeForeground": "#F8FAFE"
},
"editor.formatOnPaste": true
}
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论