如何长时间设置git cache --timeout? [英] How to set git cache --timeout for long period?

查看:199
本文介绍了如何长时间设置git cache --timeout?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Git push需要用户名和密码中,我了解了如何进行push/pulling到/从github在命令行中运行git命令时,请勿输入登录名/密码.

我找到了下一个:

  git config --global credential.helper'cache --timeout 7200' 

启用凭据缓存后,它将缓存7200秒(2小时).

我认为这太小了2个小时,并尝试通过命令设置200赫兹的速度:

  git config --global credential.helper'cache --timeout 7200000' 

我在本地服务器和远程服务器上都拥有Ubuntu 18.

但是,第二天我运行github(我认为已经过去了10到12个小时)时,它就无法工作.

此缓存选项是否有一些小时限制,或者出了什么问题?

谢谢!

解决方案

根据您的评论,似乎缓存在服务器(很少重启)上正常工作,而在笔记本电脑(经常重启)上正常工作./p>

git-credential-cache 的文档说:

此命令将凭据缓存在内存中,以供将来的Git程序使用.存储的凭据永远不会接触磁盘,并且会在可配置的超时后被忘记.

由于凭据仅存储在内存中,因此有意义的是,每次重新启动时都将丢失它们.鉴于此,我可以想到一些解决方法:

  1. 改为使用 git-credential-store ,这将保存您的凭据永久地磁盘.请注意,这将使它们完全未加密,因此根据您的安全需求,这可能无法正常工作.
  2. 继续使用缓存,但不要关闭/重新启动笔记本电脑,而应尝试使用挂起或休眠模式.这样可以保持计算机的当前状态,并防止每次使用笔记本电脑时都清除内存,因此凭据应一直保留到达到超时为止.

Here Git push requires username and password I read how pushing/pulling to/from github do not enter login/passowrd any time running git command in command line.

I found next :

git config --global credential.helper 'cache --timeout 7200'

After enabling credential caching, it will be cached for 7200 seconds (2 hour).

I decided that 2 hours too small and tried to set cach 200 hours with command :

git config --global credential.helper 'cache --timeout 7200000'

I have Ubuntu 18 both at my local server and on remote server.

But when I run github next day(I think 10-12 hours passed) it did not work.

Does this cache option has some hours restrictions or what is the problem ?

Thanks!

解决方案

Based on your comment, it seems that caching works correctly on your server (that is rarely restarted), but not your laptop (which is frequently restarted).

The documentation for git-credential-cache says this:

This command caches credentials in memory for use by future Git programs. The stored credentials never touch the disk, and are forgotten after a configurable timeout.

Since the credentials are stored in memory only, it makes sense that you would lose them whenever you restart. Given that, I can think of a few workarounds for this:

  1. Use git-credential-store instead, which will save your credentials to disk permanently. Note that this will leave them completely unencrypted, so this may not work depending on your security needs.
  2. Continue using cache, but instead of shutting off / restarting your laptop, try using suspend or hibernate mode instead. This will keep the current state of your machine and prevent clearing out the memory each time you use your laptop, so the credentials should persist until the timeout is reached.

这篇关于如何长时间设置git cache --timeout?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆