1. Generate ssh public key
ssh-keygen -t rsa -C "[email protected]"
2. Add the public key to the git repository
It is to upload the contents of the id_rsa.pub file under the .ssh folder in the user's home directory to the git repository
For the github repository, open github, find the account and add SSH, and copy the content of idrsa.pub to the key
3. Does the test work?
Connect to github here, use the command: ssh -T [email protected]
4. After the connection is successful, download the library to the local
git clone git://github.com/{yourname}/{yourRep}.git
5. Submit after modifying the code locally
Currently on master: git push origin master
The following error occurs:
fatal: remote error:
You can't push to git://github.com/{yourname}/{yourRep}.git
Use https://github.com/{yourname}/{yourRep}.git
Solution:
git remote rm origin
git remote add origin [email protected]:{yourname}/{yourRep}.git
6. Migrate the git server
git commit -m "Change repo." # 先把所有为保存的修改打包为一个commit
git remote remove origin # 删掉原来git源
git remote add origin [YOUR NEW .GIT URL] # 将新源地址写入本地版本库配置文件
git push -u origin master # 提交所有代码