简体   繁体   中英

Is there a way to generate a git patch of secret files (some files listed in .gitignore) so that I can apply these patch later or in other computer?

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.

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM