git命令行保存认证信息

Git 提供了多种方式来保存认证信息,以避免每次使用远程仓库时都需要重新输入用户名和密码。以下是几种常见的方法:

1.使用 credential.helper 进行缓存

Git 允许你缓存认证信息一段时间:

git config --global credential.helper cache

默认缓存时间为 15 分钟,可以使用以下命令更改:

git config --global credential.helper "cache --timeout=3600"

这样就会缓存 1 小时。

2.使用 credential.helper store 永久存储

如果不想频繁输入密码,可以使用:

git config --global credential.helper store

然后首次输入密码后,它会存储在 ~/.git-credentials 文件中。需要注意,这种方式不安全,因为密码是以纯文本存储的。

Related Posts