As mentioned, don't push these files to a public repo, or any repo where you think other developers on the team should not have access.
You can easily ensure these files don't somehow get committed by using a .gitignore
file:
gitignore - Specifies intentionally untracked files to ignore
See: .gitignore documentation
Here is a collection of useful .gitignore configurations: A collection of useful .gitignore templates
Rather than using encryption, it would be better to use a directory and repo structure as follows:
Project directory: All project files, no secrets.
Secrets directory: Secrets only.
Project repo: Public repository.
Secrets repo: Private repository giving access to trusted developers.
Then within your project you simply reference the necessary secrets in the secrets directory.
If you do decide to use GPG encryption (not recommended as then you have to remember not to by mistake push an un-encrypted file), you can use a basic symmetric cipher. On a Unix machine, install gpg and then use the following terminal command - it will request a password and generate an encrypted .gpg file.
-c, --symmetric encryption only with symmetric cipher
gpg -c secrets.txt