Is there a way to cache GitHub credentials for pushing commits?

后端 未结 24 3268
囚心锁ツ
囚心锁ツ 2020-11-21 05:02

I recently switched to synchronizing my repositories to https:// on GitHub (due to firewall issues), and it asks for a password every time.

Is there a way to cache t

24条回答
  •  借酒劲吻你
    2020-11-21 05:11

    I know this is not a secure solution, but sometimes you need just a simple solution - without installing anything else. And since helper = store did not work for me, I created a dummy helper:

    Create a script and put it in your users bin folder, here named credfake, this script will provide your username and your password:

    #!/bin/bash
    while read line
    do
      echo "$line"
    done < "/dev/stdin"
    echo username=mahuser
    echo password=MahSecret12345
    

    make it executable:

    chmod u+x /home/mahuser/bin/credfake
    

    then configure it in git:

    git config --global credential.helper /home/mahuser/bin/credfake
    

    (or use it without --global for the one repo only)

    and - voilá - git will use this user + password.

提交回复
热议问题