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

后端 未结 24 3270
囚心锁ツ
囚心锁ツ 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:27

    You also edit the bashrc file and add a script in it.

    This would ask for your password once when you start Git and then remembers it until you log off.

    SSH_ENV=$HOME/.ssh/environment
      
    # Start the ssh-agent
    function start_agent {
        echo "Initializing new SSH agent..."
    
        # Spawn ssh-agent
        /usr/bin/ssh-agent | sed 's/^echo/#echo/' > "${SSH_ENV}"
        echo succeeded
        chmod 600 "${SSH_ENV}"
        . "${SSH_ENV}" > /dev/null
        /usr/bin/ssh-add
    }
      
    if [ -f "${SSH_ENV}" ]; then
         . "${SSH_ENV}" > /dev/null
       ps -ef | grep ${SSH_AGENT_PID} | grep ssh-agent$ > /dev/null || {
          start_agent;
      }
    else
        start_agent;
    fi
    

提交回复
热议问题