I would like to generate a patch (using git diff) of secrets files or folders in the .gitignore file that I won't versioning so that I can easily configure an entire project on another friend's computer just cloning the project and applying these patch (using git apply).

If this is possible I can encrypt it using gpg and email it. These secret files might be certificates, passwords, directory trees, or any other file that would be sent in a normal commit if it wouldn't be in the .gitignore file.

I tried generating this patch file using git diff in many ways, but by default, it didn't work. I don't know if it's possible, but it sure would be useful.

1

There are 1 answers

1
ElpieKay On

As these files are ignored, the repository database doesn't hold their history versions. But if you have two copies of files, no matter if they are tracked by a git repository or not, you can use git diff --no-index $patha $pathb to generate the diff from the version of patha to the version of pathb.

For example, to compare /path/to/foo/ and /path/to/bar/,

git diff --no-index /path/to/foo /path/to/bar

To compare /path/to/foo/a.txt and /path/to/bar/a.txt,

git diff --no-index /path/to/foo/a.txt /path/to/bar/a.txt

To compare /path/to/foo/a.txt and /path/to/bar/b.txt,

git diff --no-index /path/to/foo/a.txt /path/to/bar/b.txt