一:HTTP方式克隆远程仓库:
1:我的远程仓库地址:https://github.com/renshanwen/python39.git
2:克隆远程仓库到本地:
ubuntu@python:~/Desktop$ git clone https://github.com/renshanwen/python39.git
正克隆到 'python39'...
remote: Enumerating objects: 5, done.
remote: Counting objects: 100% (5/5), done.
remote: Compressing objects: 100% (4/4), done.
remote: Total 5 (delta 0), reused 0 (delta 0), pack-reused 0
展开对象中: 100% (5/5), 完成.
3:配置身份信息:
ubuntu@python:~/Desktop/python39$ git config user.name '经理'
ubuntu@python:~/Desktop/python39$ git config user.email 'manager997@163.com'
4:创建自己的项目文件,并且将自己的项目提交到缓存,然后提交到本地仓库,最后提交到远程仓库。
ubuntu@python:~/Desktop/python39$ touch hello.py
ubuntu@python:~/Desktop/python39$ git add .
ubuntu@python:~/Desktop/python39$ git commit -m '我是产品经理,我要立项'
[master 9b0a286] 我是产品经理,我要立项
1 file changed, 0 insertions(+), 0 deletions(-)
create mode 100644 hello.py
ubuntu@python:~/Desktop/python39$ git push
Username for 'https://github.com': renshanwen
Password for 'https://renshanwen@github.com':
对象计数中: 3, 完成.
Delta compression using up to 4 threads.
压缩对象中: 100% (2/2), 完成.
写入对象中: 100% (3/3), 305 bytes | 305.00 KiB/s, 完成.
Total 3 (delta 1), reused 0 (delta 0)
remote: Resolving deltas: 100% (1/1), completed with 1 local object.
To https://github.com/renshanwen/python39.git
6bac8b3..9b0a286 master -> master
ubuntu@python:~/Desktop/python39$
5:让本地仓库记住密码,这样提交不用输入密码了。
设置记住密码(默认15分钟):
git config --global credential.helper cache
如果想自己设置时间,可以这样做(1小时后失效):
git config credential.helper 'cache --timeout=3600'
长期存储密码:
git config --global credential.helper store
二:配置SSH:
《一》配置SSH公钥入口
1:点击自己的settings
2:选择SSH and GPG keys
3:点击new SSH key
4:title随便写,点击add SSH key
《二》修改电脑git配置:
1:在家目录下修改:.gitconfig文件:
vim .gitconfig
[user]
email = 1173714240@qq.com
name = renshanwen
2:生成SSH公钥,三次回车到最后:
ssh-keygen -t rsa -C "1173714240@qq.com"
在根目录下,进入密钥文件夹:
cd .ssh
ll查看密钥文件
cat id_rsa.pub 查看公钥内容,并复制。
ubuntu@python:~/Desktop/python39$ ssh-keygen -t rsa -C "1173714240@qq.com"
Generating public/private rsa key pair.
Enter file in which to save the key (/home/ubuntu/.ssh/id_rsa):
Enter passphrase (empty for no passphrase):
Enter same passphrase again:
Your identification has been saved in /home/ubuntu/.ssh/id_rsa.
Your public key has been saved in /home/ubuntu/.ssh/id_rsa.pub.
The key fingerprint is:
SHA256:8Uqx1GfW0twZTQKLt7aYS/K+ggoWqY7SOIhBpkoRKTc 1173714240@qq.com
The key's randomart image is:
+---[RSA 2048]----+
| . ...oo|
|.oE . . = o+|
|.... + o B +..|
| + . . = = o |
|+ + S . o |
|oo . . . + . |
|*+o .o + . |
|X... . .+ . |
|oo .. o=. |
+----[SHA256]-----+
ubuntu@python:~/Desktop/python39$ cd .ssh/
bash: cd: .ssh/: 没有那个文件或目录
ubuntu@python:~/Desktop/python39$ cd
ubuntu@python:~$ cd .ssh/
ubuntu@python:~/.ssh$ ll
总用量 16
drwx------ 2 ubuntu ubuntu 4096 8月 24 19:01 ./
drwxr-xr-x 29 ubuntu ubuntu 4096 8月 24 18:22 ../
-rw------- 1 ubuntu ubuntu 1675 8月 24 19:01 id_rsa
-rw-r--r-- 1 ubuntu ubuntu 399 8月 24 19:01 id_rsa.pub
ubuntu@python:~/.ssh$ cat id_rsa.pub
ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQDAwaWMKEo3Jh8xjMadWkcfziN2R5vemNzL+FLWAx4EEvK7dhsPYit1dGj7g2nfFM+6jlEj5S4ZxsRoniAJ/2kNkClY2ZAoAbV4nJfTPQaG3N/cZT93ehrYRa6mk9uxp5aBY1OR3DaHWLkLEN+CKBaBNN1KrJltLxM2F9zGG8tUCLS+B0SeExT7Jg8QTp3C2cN8WWSxN4EwtMgK4UKjTqCyq3uzONQRm4mVVRkC2zqXTPYGLcUmbr/cRRapTbE+3bj0UgJWJomWXs6TzaHgAO5uYInpId9a71GY2xwSl4hXHUGiLFUrlaPbiiAmO7Q5NW/bgGZiGU/GRl1alutVpNhR 1173714240@qq.com
最后点击新的密钥,粘贴进去就好了。

浙公网安备 33010602011771号