#type/zk/zettel #a/maturity/seed # [[How git-crypt works]] [[git-crypt]] can be specified as a filter attribute for certain files using the [[gitattributes|.gitattributes]] file. Whenever a file with this filter specified is checked in, git-crypt is called to encrypt it, and when it is checked out to decrypt it. There's also a `diff` attribute, not sure yet what this one does. > [!comment] [[2024-10-25]] > I guess it's so that `git diff` shows proper diffs, and not a diff with something encrypted. --- Sowed on:: [[2024-01-09|2024-01-09]] Sources:: [[Git - gitattributes Documentation (web)]] See also:: Related references:: Further reading:: --- > [!quote] [[Git - gitattributes Documentation (web)]] > A `filter` attribute can be set to a string value that names a filter driver specified in the configuration. > > A filter driver consists of a `clean` command and a `smudge` command, either of which can be left unspecified. Upon checkout, when the `smudge` command is specified, the command is fed the blob object from its standard input, and its standard output is used to update the worktree file. Similarly, the`clean` command is used to convert the contents of worktree file upon checkin. By default these commands process only a single blob and terminate. If a long running `process` filter is used in place of `clean` and/or `smudge` filters, then Git can process all blobs with a single filter command invocation for the entire life of a single Git command, for example `git add --all`. If a long running `process`filter is configured then it always takes precedence over a configured single blob filter. See section below for the description of the protocol used to communicate with a `process` filter. > > ... > > Another use of the content filtering is to store the content that cannot be directly used in the repository (e.g. a UUID that refers to the true content stored outside Git, or an encrypted content) and turn it into a usable form upon checkout (e.g. download the external content, or decrypt the encrypted content). > [!quote] [[Git - gitattributes Documentation (web)]] > The attribute `diff` affects how Git generates diffs for particular files. It can tell Git whether to generate a textual patch for the path or to treat the path as a binary file. It can also affect what line is shown on the hunk header `@@ -k,l +n,m @@` line, tell Git to use an external command to generate the diff, or ask Git to convert binary files to a text format before generating the diff.