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

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

    Usually you have a remote URL, something like this,

    git remote -v
    
    origin    https://gitlab.com/username/Repo.git (fetch)
    origin    https://gitlab.com/username/Repo.git (push)
    

    If you want to skip username and password while using git push, try this:

     git remote set-url origin https://username:password@gitlab.com/username/Repo.git
    

    I've just added the same URL (with user details including password) to origin.

    NOTE: It doesn't work if username is an email Id.

    git remote -v
    
    origin    https://username:password@gitlab.com/username/Repo.git (fetch)
    origin    https://username:password@gitlab.com/username/Repo.git (push)
    

提交回复
热议问题