Can I hold git credentials in environment variables?

前端 未结 3 797
死守一世寂寞
死守一世寂寞 2020-12-13 19:25

I\'d like to create a very simple shell script, which will ultimately be called by another application, that updates a local git repository:

#!/bin/bash

cd          


        
3条回答
  •  我在风中等你
    2020-12-13 20:02

    You can set the username in the git config with:

    git config credential.https://github.com.username $GIT_USER
    

    Then you can set the GIT_ASKPASS environment variable to a script that will provide the password:

    export GIT_ASKPASS=/path/to/git_env_password.sh
    

    The contents of git_env_password.sh would be:

    #!/bin/bash
    echo $GIT_PASSWORD
    

    N.B: This will store the username in the git config, so if you are not okay with that use another solution.

    For more info consult the gitcredentials man page.

提交回复
热议问题