I have several sensitive images on a computer vision program I created that I don't want public but I want to share the main python code. Is there a way to make only certain files in a github repository public while keeping other files private?
2 Answers
You could use git-crypt for this:
git-crypt lets you freely share a repository containing a mix of public and private content. git-crypt gracefully degrades, so developers without the secret key can still clone and commit to a repository with encrypted files. This lets you store your secret material (such as keys or passwords) in the same repository as your code, without requiring you to lock down your entire repository.
https://github.com/AGWA/git-crypt
This lets you check the files in and share them (or not) with collaborators.
Comments
Add sensitive files to your .gitignore file, which will prevent them from being picked up by Git:
# Add a specific file: path/to/sensitive/file.txt # Add an entire folder a/whole/folder # Add all files of type "txt" *.txt You can find documentation for .gitignore here: https://git-scm.com/docs/gitignore
Note that this will not make git "forget" already tracked files, to untrack files without deleting them from your computer, you'll have to git rm --cached file_to_untrack.txt. Omit --cached to delete from your computer as well.