简体中文 ▾
Localized versions of git-credential-cache manual
Topics ▾
Email
Latest version
▾
git-credential-cache last updated in 2.49.0
Changes in the git-credential-cache manual
Setup and Config
Getting and Creating Projects
Basic Snapshotting
Branching and Merging
Sharing and Updating Projects
Inspection and Comparison
Patching
Debugging
External Systems
Server Admin
Guides
- gitattributes
- Command-line interface conventions
- Everyday Git
- Frequently Asked Questions (FAQ)
- Glossary
- Hooks
- gitignore
- gitmodules
- Revisions
- Submodules
- Tutorial
- Workflows
- All guides...
Administration
Plumbing Commands
- 2.49.1 → 2.54.0 no changes
-
2.49.0
2025-03-14
- 2.43.1 → 2.48.2 no changes
-
2.43.0
2023-11-20
- 2.40.1 → 2.42.4 no changes
-
2.40.0
2023-03-12
- 2.39.1 → 2.39.5 no changes
-
2.39.0
2022-12-12
- 2.18.1 → 2.38.5 no changes
-
2.18.0
2018-06-21
- 2.14.6 → 2.17.6 no changes
-
2.13.7
2018-05-22
- 2.9.5 → 2.12.5 no changes
-
2.8.6
2017-07-30
- 2.1.4 → 2.7.6 no changes
-
2.0.5
2014-12-17
描述
该命令会缓存凭证,供未来的 Git 程序使用。 存储的凭据保存在 cache-daemon 进程的内存中(而不是写入文件),并在可配置的超时后被遗忘。如果 cache-daemon 死机,例如系统重启,证书会更快被遗忘。缓存可通过 Unix 域套接字访问,并通过文件系统权限限制为当前用户访问。
你可能不想直接调用这条命令;它的目的是作为 Git 其他部分的凭证助手。请参阅 gitcredentials[7] 或下面的 例子。
实例
这个助手的意义在于减少你必须输入用户名或密码的次数。比如说:
$ git config credential.helper cache $ git push http://example.com/repo.git Username: <输入你的用户名> Password: <输入你的密码> [再工作 5 分钟] $ git push http://example.com/repo.git [自动使用您的证书]
您可以通过 credential.helper 配置变量提供选项(本例将缓存时间增加到 1 小时):
$ git config credential.helper 'cache --timeout=3600'
个人访问令牌
有些远程接受个人访问令牌(personal access token),这类令牌通常是随机生成的,不易记忆。它们的有效期一般为数周或数月。
git-credential-cache 天生不适合持久存储个人访问令牌。缓存超时后,凭据就会被遗忘。即使你配置了很长的超时时间,只要守护进程退出,凭据仍会丢失。
为了避免频繁重新生成个人访问令牌,请配置一个具有持久存储能力的凭据辅助工具。或者,也可以配置 OAuth 凭据辅助工具来自动生成凭据。请参见 gitcredentials[7] 中的“Available helpers”和“OAuth”两节。
GIT
属于 git[1] 文档