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

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

    Things are a little different if you're using two-factor authentication as I am. Since I didn't find a good answer elsewhere, I'll stick one here so that maybe I can find it later.

    If you're using two-factor authentication, then specifying username/password won't even work - you get access denied. But you can use an application access token and use Git's credential helper to cache that for you. Here are the pertinent links:

    • Setting up the command-line to work with 2-factor auth (search for section titled "How does it work for command-line Git?")
    • Credential caching

    And I don't remember where I saw this, but when you're asked for your username - that's where you stick the application access token. Then leave the password blank. It worked on my Mac.

提交回复
热议问题