资料来自stackoverflow.......我这里是拿来党最喜欢的demo
来,跟我左右右手一个慢动作
cd ~/.ssh && ssh-keygen
Enter file in which to save the key (/Users/baidu/.ssh/id_rsa): 这里输入对应的名称,比如 github_rsa, hzz_rsa, baidu_rsa (你要是都存id_rsa,那就只有一个key了,别问我为什么,按我说的做,吻我)
cat hzz_rsa.puh
好,复制到网站上对应的地方去。。。然后修改名称为你喜欢的名称
git config --global user.name "hzz"
伟大的stackoverflow是万能的!
First start by setting up your own public/private key pair set. This can use either DSA or RSA, so basically any key you setup will work. On most systems you can use ssh-keygen.
- First you'll want to cd into your .ssh directory. Open up the terminal and run:
cd ~/.ssh && ssh-keygen
-
Generating public/private rsa key pair.
Enter file in which to save the key (/Users/baidu/.ssh/id_rsa):-
- enter the name you like (ps: zz add)
-
- Next you need to copy this to your clipboard.
- On OS X run:
cat id_rsa.pub | pbcopy
- On Linux run:
cat id_rsa.pub | xclip
- On Windows (via Cygwin/Git Bash) run:
cat id_rsa.pub | clip
- On OS X run:
- Add your key to your account via the website.
-
- add you will get a user.name, you can change it as you like
-
- Finally setup your .gitconfig.
git config --global user.name "bob"
git config --global user.email bob@...
(don't forget to restart your command line to make sure the config is reloaded)
Thats it you should be good to clone and checkout.