Yes, you can set your Git credentials as environment variables in your remote environment so that pip can install the library using the "normal" GitHub link. Here are the steps you can follow:
Set up a Git credential helper on your remote host. You can do this by running the following command in your terminal:
git config --global credential.helper cache
This will tell Git to cache your credentials for a period of time so that you don't have to enter them every time you interact with the remote repository.
Set the following environment variables on your remote host:
export GITHUB_USER=<your_github_username>
export GITHUB_TOKEN=<your_github_personal_access_token>
You can generate a personal access token by following the instructions here: https://docs.github.com/en/authentication/keeping-your-account-and-data-secure/creating-a-personal-access-token
Be sure to keep your token secure and never share it with anyone.
Update your requirements.txt file to use the "normal" GitHub link instead of the URL with credentials. For example:
git+https://github.com/user/project.git@{version}
Make sure to remove any credentials from the URL.
Install the library using pip on your remote host:
pip install -r requirements.txt
Pip should now be able to install the library using the "normal" GitHub link and the credentials will be retrieved from the environment variables you set.
Note: If you are using a virtual environment on your remote host, you will need to set the environment variables within the virtual environment using the source command before running pip install.