How to transfer merge of git files with preliminary and subsequent processing?

I would like to be able to call some preprocessing of the files before Git tries to merge them, and the post-process the combined result. The general idea here is that some files are difficult to automatically merge as-is, but can be converted to an easier form for processing. Here is my specific use case:

I have a repository of mostly not very sensitive data. Inside this repository, I have some encrypted sensitive data in a file named sensitive.pgp. I like this convention because I don’t need to trust that my repository is managed securely, I just have to trust encryption and password. Of course, the trick is that Git cannot combine encrypted text, so if you sensitive.pgpchange in two checks at once, there is no possibility of merging - even if the changes in the clear text are easily separated. The manual workflow is as follows:

  • Merge conflict detected for sensitive.pgp.
  • Run git -mergetool. The tool also cannot merge PGP files.
  • Now I have temporary files for my version, base version and remote version.
  • Decrypt all three files.
  • Call my merge tool in decrypted versions.
  • Encrypt the result.
  • git-new is new sensitive.pgp.

I would like to tell Git to apply my preprocessing and postprocessing before it even tries to merge, so it can handle this automatically. I can imagine many other scenarios with the same general pattern: Almost every time you have a compressed file format with a textual basic structure (e.g. PDF, OpenOffice, Word), for example.

Any suggestions?

+5
source share
1 answer

You have several options:

  • checkout/checkin .gitattributes (. git help attributes), ( )
  • (. git help attributes merge.<driver>.* git help config)
  • (. git help mergetool mergetool.<tool>.* git help config), ,

git , , , git mergetool. , , .

+4

All Articles