Filter out certain parts of a json file on git commit

236 Views Asked by At

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
}
0

There are 0 best solutions below