Git set user name password example code


Git set user name and password

Set git user name / email address

git config --global [username]
git config --global [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

  repositoryformatversion = 0
  filemode = true
  bare = false
  logallrefupdates = true
[remote "origin"]
  url =
  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
  helper = store


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
[email protected]

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!