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 "yourmail@qq.com"
創建一個新檔案
$ 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 git@gitee.com: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 "yourmail@qq.com"
建立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
在Gitee里添加公鑰

Linux端發到遠程倉庫
# git remote add origin git@gitee.com:shuaihewen/gitroot.git
# git push -u origin master

轉載請註明出處,本文鏈接:https://www.uj5u.com/qita/302883.html
標籤:其他
