如何避免git每次提交都输入密码

时间:2022-10-06 21:50:26
在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工具,不过现在好要*才能下载了。