Several ideas... Public Key Cryptography is the most flexible answer.
Obfuscation (for code only)
For the parts of the code you want to hide, could you put them in a different project, compile them, and check in only the compiled code, not the source? This is not encryption and not suitable for encrypting passwords or keys. People can still reverse-engineer your compiled code, but they don't get the source.
Private GIT repository
Does it have to be a public git repository?
Can you store this info in a protected file in the home directory of the user account the application runs under? I would copy the way ssh does this with ~/.ssh/id_rsa and a chmod of 600. Failing that, an environment variable could be used. You need somewhere on the server to store some kind of key, or there is no way you can protect anything.
Symmetric Cryptography (just for you)
If you are the sole developer, you could put a key on the server and have that same key on your machine and use a symmetric encryption scheme to protect some data like a password or certificate. Sharing a symmetric key with friends gets messy.
Asymmetric Cryptography (for multiple developers)
If other developers need to check secret things into a public git repository, , public-key/private-key (asymmetric) cryptography was made for this kind of thing. Install a private key on your your server (do not check it into source control!) and generate a public key from it. Encrypt your secret data using the server's public key. Only the server can decrypt that data using its private key. You can even check the public key into source control so that other people can encrypt data using the same public key and only the server can decrypt it.
Openssl is probably the only cryptography tool you'll ever need. Do not write your own cryptography algorithm or your own implementation of a published algorithm.
If the "server" is a web server that uses https, then you should already have a secure keystore of some kind on the server to store the private key in. It's kind of mind-blowing that a hosting company wouldn't make allowances for this. Maybe they have some hints on how others solve the challenge you are facing?