当前位置:首页 > 其他 > git > git设置用户名密码

git设置用户名密码

DChen3年前 (2021-05-21)git3.7 K0

本文为记录贴,主要只是简单的记录一下git的一些基本操作,一些关于git用户账号的操作指令等。如果是git小白或者初学者可以了解一下

1、设置git用户名、邮箱

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

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


2、git保存用户名/密码
这里主要是配置一个config项,有两个方法,基本上原理都是一样,都是修改.git/config文件
1)、使用如下命令,修改config文件即可保存
echo "[credential]" >> .git/config
echo "helper = store" >> .git/config

2)、直接修改.git/config文件,在linux/mac下可以直接使用vim工具修改config文件

$ 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
:wq

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


3、git config查看配置
使用git config --list查看已设配置
feiqianyousadeMacBook-Pro:xt_GtpU yousa$ git config --list
core.excludesfile=/Users/yousa/.gitignore_global
user.name=Miss-you
user.email=snowfly1993@gmail.com
core.repositoryformatversion=0
core.filemode=true
core.bare=false
core.logallrefupdates=true
core.ignorecase=true
core.precomposeunicode=true
remote.origin.url=https://github.com/Miss-you/xt_GTPU.git
remote.origin.fetch=+refs/heads/*:refs/remotes/origin/*
branch.master.remote=origin
branch.master.merge=refs/heads/master


取消

感谢您的支持,我会继续努力的!

扫码支持
扫码打赏,你说多少就多少

打开支付宝扫一扫,即可进行扫码打赏哦

版权声明:本文由“憨小猪”发布,如需转载请注明出处。

本文链接:https://www.phper.red/post/86.html

标签: git

发表评论

访客

看不清,换一张

◎欢迎参与讨论,请在这里发表您的看法和观点。