当前位置:首页 » 硬盘大全 » 命令行修改git缓存密码
扩展阅读
webinf下怎么引入js 2023-08-31 21:54:13
堡垒机怎么打开web 2023-08-31 21:54:11

命令行修改git缓存密码

发布时间: 2023-02-18 21:18:03

㈠ 如何处理git每次提交都输入密码

在ubuntu系统中,如何避免git每次提交都输入用户名和密码?

操作步聚如下:
1: cd 回车;进入当前用户目录下;

2: vim .git-credentials (如果没有安装vim 用其它编辑器也可以或 sudo apt-get install vim 安装一个)

3:按照以下格式输入内容:
https://{username}:{password}@github.com
其中username,password,github.com 都换成你自己的内容

4:保存退出后执行下面命令
git config --global credential.helper store
执行完后
/home/用户名/.gitconfig 会新增一项
helper = store
这是再执行git push/pull的时候就不会在要求你输入密码了。

当然,还有一种方式就是在git clone 的时候,不用https://的形式,而用git@git (ssh)的形式。这种方式也可以避免每次都要输密码。

最后,如果是在mac os x或windows平台下,还可以用sourcetree 这样的ide工具,不过现在好要FQ才能下载了。

㈡ git重置密码和用户名

当遇到验证失败时可以尝试用下面两种方式修改 1. 进入“控制面板”=>"用户账户"=>"凭据管理器"=>"管理Windows凭据" 找到对应的git凭据删除,再次使用git时会重新要求输入账户密码 2. 使用cmd命令 在cmd中输入 <pre style="margin: 0px; padding: 0px; white-space: pre-wrap; overflow-wrap: break-word; font-family: "Courier New" !important; font-size: 12px !important;">git credential-manager uninstall</pre> 该命令会重置本地的所有密码

㈢ 怎样连接git远程仓库,设置用户名和密码

当使用HTTPS协议推送代码到Git仓库时,发现每次都需要输入密码,操作起来非常麻烦。下面介绍几种免去输入密码的方法。
HTTPS协议推送
使用HTTPS协议,有一种简单粗暴的方式是在远程地址中带上密码。
> git remote set-url origin http://yourname:[email protected]/yourname/project.git

还有一种方法,是创建文件存储Git用户名和密码。
以Windows环境为例,在%USERPROFILE%目录中(一般为C:\Users\yourname),打开Git Bash命令行,创建文件
> touch .git-credentials

在文件中输入仓库域名,这里使用了bitbucket.org。
https://yourname:[email protected]

在CMD终端中设置在全局Git环境中,长期存储密码
> git config --global credential.helper store

其他设置密码方式
记住密码(默认15分钟):git config --global credential.helper cache
自定义存储时间:git config credential.helper 'cache --timeout=3600'
SSH协议推送
如果原来的推送地址协议是HTTPS,可以通过换成SSH协议,在远程仓库添加SSH Key来实现推送时免账户密码输入。
> git remote -v // 查看远程地址
> git remote rm origin // 删除原有的推送地址
> git remote add origin [email protected]:<用户名>/版本库名

或者
> git remote -v
> git remote set-url origin [email protected]:<用户名>/版本库名

执行推送。
> git push -u origin master

发现提示权限不够。
The authenticity of host 'bitbucket.org (104.192.143.1)' can't be established.
RSA key fingerprint is SHA256:.
Are you sure you want to continue connecting (yes/no)? yes
Warning: Permanently added 'bitbucket.org,104.192.143.1' (RSA) to the list of kn
own hosts.
Permission denied (publickey).
fatal: Could not read from remote repository.

Please make sure you have the correct access rights
and the repository exists.

需要在本地创建该帐号的RSA Key。可以参考以下两篇文章:
Windows下配置SSH连接Github
Git如何在本地生成多个SSH key
然后再执行推送。
> git push -u origin master

就可以推送成功了。

㈣ git如何设置账号密码从而每次项目中的组员更新或者提交代码的时候都需要输入账号和密码

插入如下代码使项目中的组员每次修改数据都要输入账号和密码:

  • gitconfig--globaluser.name[username]

  • gitconfig--globaluser.password[userpassword]

PS:想要保存密码,则需要插入如下代码:git config –global credential.helper store。

㈤ 清除git中缓存的凭证(用户名及密码)

运行一下命令缓存输入的用户名和密码:

清除掉缓存在git中的用户名和密码