We don't recommend storing anything that you want to keep secret in a public GitHub repository, even in an encrypted form. There's too much possibility for a slip-up exposing valuable credentials which can then cost you or your company a lot of money and time.
Additionally, credentials typically aren't "versioned" alongside the code. For example, let's say that your project has been being worked on for a couple years. Let's also say that in that time, you've rotated the credentials a couple times. If you go back to an old version of the code and try to boot it up, you may be using an old, expired set of credentials. What you really want is the current set of credentials with the old code. So they really should be stored separately.
I hope that helps!