看啥

导航

二、git远程仓库

  • github (国外)
  • gitee(国内)
  • gitlab (自建)
    image
    https://gitee.com/
    新建仓库
    image
    image
  • 使用简介
    image
    下载远程仓库
git clone https://gitee.com/bennyda/test01.git

# 设置用户名和邮箱
git config --global user.name "tom"
git config --global user.email "tom@163.com"

[root@7 test01]# cd .git/
[root@7 .git]# cat config
[core]
	repositoryformatversion = 0
	filemode = true
	bare = false
	logallrefupdates = true
[remote "origin"]
	url = https://gitee.com/bennyda/test01.git
	fetch = +refs/heads/*:refs/remotes/origin/*
[branch "master"]
	remote = origin
	merge = refs/heads/master

手动建仓库将本地代码提交到远程仓库

git config --global user.name "tom"
git config --global user.email "tom@163.com"
mkdir test01
cd test01
git init
Initialized empty Git repository in /root/test01/.git/
touch README.md
git add README.md
git commit -m "first commit"
[root@7 test01]# git push -u origin master
Username for 'https://gitee.com': 15573146694
Password for 'https://15573146694@gitee.com': 
Counting objects: 3, done.
Writing objects: 100% (3/3), 214 bytes | 0 bytes/s, done.
Total 3 (delta 0), reused 0 (delta 0)
remote: Powered by GITEE.COM [GNK-6.0]
To https://gitee.com/bennyda/test01.git

账号为邮箱或手机号码

使用SSh将我们的代码提交到远程连接免密码

1、在本地生成公钥

ssh-key -t rsa
cat /root/.ssh/id_rsa.pub
ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQCttYhNdXvJL/y8Ox8ERsvE78yN9+ViaXX3iihWeePDQsQMo4SptHb6FICD5BfDGWv2ilKLb80VAiyxoepkoq5Ev6QIvZ/BFawv25VgGzYOKbSRR1NQcbl9/hSzXFIVxSaowXwVuKNDA4nBHg+Nd7xbaDn8nu0o1RyucRAMC/6H9QfHoMhzaqLa0lH2+Z739vjsII8JrK03iGlp54wj4h0pPR8MJSy5nGCAc1l5FzJLw6HVTs1fWr3QSjbSBa2ld6HoLq+HUdHTGhs3+K7Cf/cBcLLNFiFRLnSXhol+ty+6E9QWtJL476vS8a8ZlxSt+rovf7OI+kNFyJrIw8Oy3aT1 root@7.com
2、在`https://gitee.com/profile/sshkeys`填写公钥
![image](https://img2020.cnblogs.com/blog/2472448/202108/2472448-20210818154950376-2082817886.png)

3、修改仓库配置文件替换url连接
![image](https://img2020.cnblogs.com/blog/2472448/202108/2472448-20210818153920328-1152750624.png)
```bash
vim .git/config
url = git@gitee.com:bennyda/test01.git\

检测ssh连接

[root@7 test01]# echo "123">index.html
[root@7 test01]# git add index.html
[root@7 test01]# git commit -m 'one' 
[master b4ef445] one
 1 file changed, 1 insertion(+)
 create mode 100644 index.html
[root@7 test01]# git push -u origin master
The authenticity of host 'gitee.com (212.64.62.183)' can't be established.
ECDSA key fingerprint is SHA256:FQGC9Kn/eye1W8icdBgrQp+KkGYoFgbVr17bmjey0Wc.
ECDSA key fingerprint is MD5:27:e5:d3:f7:2a:9e:eb:6c:93:cd:1f:c1:47:a3:54:b1.
Are you sure you want to continue connecting (yes/no)? yes
Warning: Permanently added 'gitee.com,212.64.62.183' (ECDSA) to the list of known hosts.
Counting objects: 4, done.
Compressing objects: 100% (2/2), done.
Writing objects: 100% (3/3), 277 bytes | 0 bytes/s, done.
Total 3 (delta 0), reused 0 (delta 0)
remote: Powered by GITEE.COM [GNK-6.0]
To git@gitee.com:bennyda/test01.git
   1f87e28..b4ef445  master -> master
Branch master set up to track remote branch master from origin.

posted on 2021-08-18 23:36  看啥  阅读(111)  评论(0编辑  收藏  举报