liunx下git设置用户名和密码(含单独项目)

设置git用户名/邮箱

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

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

注:若是是单项目,就在项目文件夹下设置,去掉global;github

可是这个仅仅是设置用户名密码,若是你的git 源每次操做须要你输入用户名/密码验证,你依然须要每次设置,那么该如何办呢?ubuntu

git保存用户名密码

这里主要是配置一个config项vim

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

1.使用以下命令,修改config文件便可保存fetch

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

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

在linux/mac下能够直接使用vim工具修改config文件spa

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

##保存

这样就能够保存用户名密码,不用每次都输入了!code

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

这样配置以后,只要输入一次帐户和密码就能够了

相关文章
相关标签/搜索