Git set user name password example code

Time:2020-11-25

Git set user name and password

Set git user name / email address


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

But this is only to set the user name and password. If your git source needs you to input the user name / password for verification every time, you still need to set it every time. What should I do?

Git saves the user name and password

This is mainly to configure a config item

There are two methods, basically the same principle, are to modify the. Git / config file

1. Use the following command to modify the config file to save


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

2. Modify the. Git / config file directly

In Linux / Mac, you can directly use VIM tool to modify the config file

[email protected]:~/kernel-code/kernel-netfilter-sample-code$ vim .git/config

##It is amended as follows

[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
##This is mainly the last two lines. If you don't want to save them, you can delete them
[credential]
  helper = store

##Preservation

In this way, you can save the user name and password, and you don’t have to enter it every time!

Git config view configuration

Use git config — list to view the set configuration


feiqianyousadeMacBook-Pro:xt_GTPU yousa$ git config --list
core.excludesfile=/Users/yousa/.gitignore_global
user.name=Miss-you
[email protected]
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

This article about git set user name password example code article introduced here, more related git user name password content, please search the previous articles of developeppaer or continue to browse the related articles below, I hope you can support developeppaer more in the future!