Git远程推送时设置用户名和密码
来源:互联网 发布:itc网络广播功放说明书 编辑:程序博客网 时间:2024/06/03 17:36
原文地址:http://www.jianshu.com/p/7182b2faab84
当使用HTTPS协议推送代码到Git仓库时,发现每次都需要输入密码,操作起来非常麻烦。下面介绍几种免去输入密码的方法。
HTTPS协议推送
使用HTTPS协议,有一种简单粗暴的方式是在远程地址中带上密码。
> git remote set-url origin http://yourname:password@bitbucket.org/yourname/project.git
还有一种方法,是创建文件存储Git用户名和密码。
以Windows环境为例,在%USERPROFILE%目录中(一般为C:\Users\yourname),打开Git Bash命令行,创建文件
> touch .git-credentials
在文件中输入仓库域名,这里使用了bitbucket.org
。
https://yourname:password@bitbucket.org
在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 git@github.com:<用户名>/版本库名
或者
> git remote -v> git remote set-url origin git@github.com:<用户名>/版本库名
执行推送。
> git push -u origin master
发现提示权限不够。
The authenticity of host 'bitbucket.org (104.192.143.1)' can't be established.RSA key fingerprint is SHA256:zzXQOXSRBEiUtuE8AikJYKwbHaxvSc0ojez9YXaGp1A.Are you sure you want to continue connecting (yes/no)? yesWarning: Permanently added 'bitbucket.org,104.192.143.1' (RSA) to the list of known hosts.Permission denied (publickey).fatal: Could not read from remote repository.Please make sure you have the correct access rightsand the repository exists.
需要在本地创建该帐号的RSA Key。可以参考以下两篇文章:
Windows下配置SSH连接Github
Git如何在本地生成多个SSH key
然后再执行推送。
> git push -u origin master
就可以推送成功了。
阅读全文
0 0
- Git远程推送时设置用户名和密码
- Git 每次提交时的用户名和密码设置
- git设置用户名密码
- git设置用户名密码
- git设置用户名密码
- git设置用户名密码
- 每次git push到远程库都要输入用户名和密码?
- 解决git指令更新远程仓库github时每次都要输入用户名和密码问题
- git客户端第一次使用,设置用户名和密码
- 设置Git不需要每次push都输入用户名和密码
- 在idea中设置记住git的用户名和密码
- Github:每次git push推送的时候都需要输入git的用户名和密码
- 保存Git用户名和密码
- git记住用户名和密码
- git 保存用户名和密码
- git记住用户名和密码
- Git 保存用户名和密码
- Git 保存用户名和密码
- 算法每日禅
- 简单易懂的秒杀服务
- BZOJ 1639: [Usaco2007 Mar]Monthly Expense 月度开支
- appium+python官方sample code(三)
- 类加载过程ClassLoader分析
- Git远程推送时设置用户名和密码
- Codeforces848C Goodbye Souvenir -- CDQ分治
- 《MySQL入门很简单》学习笔记(8)之第8章视图(关键词:数据库/MySQL/创建视图/修改视图/查看视图/删除视图)
- spring mvc配置理解2
- 用python字典完成登陆
- HDU1495 非常可乐 —— BFS + 模拟
- 9-2 学习笔记 html复习
- 网易等差数列(提交版)
- 学生信息管理系统错误总结