1.学习要求
1.1可以将Gitee连接到本地
1.2可以将Gitee连接到Linux
2.配置安装
2.1 git安装
Windows端安装地址: Git for Windows
Linux端 安装: yum install git -y
3.开始操作
3.1 本地连接Gitee
在git bash 中进入H:/www/githome
$ git init
输入用户信息
$ git config --global user.name "name"
$ git config --global user.email "[email protected]"
创建一个新文件
$ echo "hello world" > 1.txt
添加本地文件
$ git add 1.txt
提交到本地库
$ git commit -m "add new file 1.txt"
在Gitee中加入公钥(将本地C:/用户/user/.ssh/id_rsa_pub里的公钥提交到Gitee中)
本地库连接远程库
$ git remote add origin [email protected]:your/githome.git
文件发送到远程库上 第一次加 “-u”
$ git push -u origin master
提示以下
The authenticity of host 'gitee.com (180.97.125.228)' can't be established.
ED25519 key fingerprint is SHA256:+ULzij2u99B9eWYFTw1Q4ErYG/aepHLbu96PAUCoV88.
This key is not known by any other names
下面选项填yes
Are you sure you want to continue connecting (yes/no/[fingerprint])? yes
Warning: Permanently added 'gitee.com' (ED25519) to the list of known hosts.
Enumerating objects: 3, done.
Counting objects: 100% (3/3), done.
Writing objects: 100% (3/3), 223 bytes | 223.00 KiB/s, done.
Total 3 (delta 0), reused 0 (delta 0), pack-reused 0
remote: Powered by GITEE.COM [GNK-6.1]
To gitee.com:your/githome.git
* [new branch] master -> master
Branch 'master' set up to track remote branch 'master' from 'origin'.
到此连接就成功了
3.2 linux 连接Gitee
在linux中安装git
# yum install git -y
# git version
git version 1.8.3.1
配置基本信息
# git config --global user.name "name"
# git config --global user.email "[email protected]"
建立git仓库
# mkdir /data/gitroot
# cd /data/gitroot
初始化仓库
# git init
# Initialized empty Git repository in /data/gitroot/.git/
创建一个新的文件
# echo "hello world">2.txt
把2.txt添加到仓库
# git add 2.txt
# git commit -m "add new file 2.txt"
在Linux里查看你设置的SSH公钥
# cd .ssh/
# cat id_rsa.pub
Linux端发到远程仓库
# git remote add origin [email protected]:shuaihewen/gitroot.git
# git push -u origin master