首页 > 开发 > 综合 > 正文

git设置用户名密码的示例代码

2020-10-08 16:08:35
字体:
来源:转载
供稿:网友

git设置用户名密码

设置git用户名/邮箱

git config --global user.name [username]git config --global user.email [email]

但是这个仅仅是设置用户名密码,如果你的git 源每次操作需要你输入用户名/密码验证,你依然需要每次设置,那么该如何办呢?

git保存用户名密码

这里主要是配置一个config项

有两个方法,基本上原理都是一样,都是修改.git/config文件

1.使用如下命令,修改config文件即可保存

echo "[credential]" >> .git/configecho "  helper = store" >> .git/config

2.直接修改.git/config文件

在linux/mac下可以直接使用vim工具修改config文件

ubuntu@VM-7-212-ubuntu:~/kernel-code/kernel-netfilter-sample-code$ vim .git/config##修改成如下[core]  repositoryformatversion = 0  filemode = true  bare = false  logallrefupdates = true[remote "origin"]  url = https://github.com/Miss-you/kernel-netfilter-sample-code.git  fetch = +refs/heads/*:refs/remotes/origin/*[branch "master"]  remote = origin  merge = refs/heads/master##主要是后面这两行,如果不想保存,则删除即可[credential]  helper = store##保存

这样就可以保存用户名密码,不用每次都输入了!

git config查看配置

使用git config --list查看已设配置

feiqianyousadeMacBook-Pro:xt_GTPU yousa$ git config --listcore.excludesfile=/Users/yousa/.gitignore_globaluser.name=Miss-youuser.email=snowfly1993@gmail.comcore.repositoryformatversion=0core.filemode=truecore.bare=falsecore.logallrefupdates=truecore.ignorecase=truecore.precomposeunicode=trueremote.origin.url=https://github.com/Miss-you/xt_GTPU.gitremote.origin.fetch=+refs/heads/*:refs/remotes/origin/*branch.master.remote=originbranch.master.merge=refs/heads/master

到此这篇关于git设置用户名密码的示例代码的文章就介绍到这了,更多相关git 用户名密码内容请搜索错新网以前的文章或继续浏览下面的相关文章希望大家以后多多支持错新网!

发表评论 共有条评论
用户名: 密码:
验证码: 匿名发表