2. 企業(yè)源代碼管理工具-Git

一、什么是Git

Git是一個(gè)開(kāi)源的分布式版本控制系統(tǒng),可以有效、高速地處理從很小到非常大的項(xiàng)目版本管理。

二、Git與SVN對(duì)比

  1. 共同點(diǎn)
    都是用來(lái)存放代碼和版本控制
  2. 區(qū)別
    a. 工作模式:git是分布式;svn是中心化(集中化)。
    b. 使用上:git入門(mén)周期長(zhǎng),但目前使用率高;svn入門(mén)簡(jiǎn)單。
    c. 分支:git創(chuàng)建和維護(hù)分支方便;svn創(chuàng)建和維護(hù)分支繁瑣。

三、部署Git

1.1 部署在window上

下載地址[Git - Downloading Package (git-scm.com)](https://git-scm.com/download/win)
根據(jù)系統(tǒng)選擇32位或64位

1.2 部署在macOS上

#需要先安裝brew
$ brew install git

詳細(xì)安裝流程傳送門(mén)

1.3 部署在linux上

#centos/redhat
yum -y install git 

#debian/ubuntu
apt install -y git

這里只介紹常用的linux版本,其它linux系統(tǒng)參考git官網(wǎng)
Git (git-scm.com)

1.4 安裝新版本教程

首先在Github 下載最新版本
這里可以選擇版本和對(duì)應(yīng)的壓縮包進(jìn)行下載(這里可以將鏈接復(fù)制到linux中通過(guò)wget下載)


在2022年2月14日時(shí)(這是一個(gè)有趣的日期!??!哈哈哈),最新版為2.35.1

#測(cè)試環(huán)境
[root@git~]# cat /etc/redhat-release     
CentOS Linux release 7.9.2009 (Core)      #系統(tǒng)版本
[root@git~]# uname -r
3.10.0-1160.el7.x86_64                    #內(nèi)核版本

#下載最新版并解壓
[root@git~]# wget https://github.com/git/git/archive/refs/tags/v2.35.1.tar.gz
[root@git~]# tar xf v2.35.1.tar.gz 

#安裝軟件依賴(lài)包
[root@git~]# yum -y install curl-devel expat-devel gettext-devel openssl-devel zlib-devel gcc perl-ExtUtils-MakeMaker

#編譯安裝
[root@git~]# cd git-2.35.1/
[root@git~/git-2.35.1]# make prefix=/usr/local/git all
[root@git~/git-2.35.1]# make prefix=/usr/local/git install

#卸載低版本的git
[root@git~]# rpm -qa git
git-1.8.3.1-23.el7_8.x86_64
[root@git~]# rpm -e perl-Git-1.8.3.1-23.el7_8.noarch git-1.8.3.1-23.el7_8.x86_64 gettext-devel-0.19.8.1-3.el7.x86_64 intltool-0.50.2-7.el7.noarch

#配置環(huán)境變量
[root@git~/git-2.35.1]# vim /etc/profile.d/git.sh
[root@git~/git-2.35.1]# cat /etc/profile.d/git.sh
export PATH=$PATH:/usr/local/git/bin
[root@git~/git-2.35.1]# . /etc/profile.d/git.sh

#測(cè)試
[root@git~/git-2.35.1]# git version
git version 2.35.1

四、Git詳解

4.1 Git初使用-開(kāi)發(fā)階段

#配置用戶(hù)
[root@git~]# git config --global user.name 'yunweixiaoyu'
[root@git~]# git config --global user.email  'xxxx@qq.com'
[root@git~]# git config --global color.ui true
[root@git~]# git config --global --list
user.name=yunweixiaoyu
user.email=xxxx@qq.com
color.ui=true
[root@git~]# cat .gitconfig
[user]
    name = yunweixiaoyu
    email = xxxx@qq.com
[color]
    ui = true


#創(chuàng)建項(xiàng)目代碼目錄
[root@git~]# mkdir -p /project/test/app
[root@git~]# cd /project/test/app


#對(duì)目錄進(jìn)行初始化
[root@git/project/test/app]# git init 
hint: Using 'master' as the name for the initial branch. This default branch name
hint: is subject to change. To configure the initial branch name to use in all
hint: of your new repositories, which will suppress this warning, call:
hint: 
hint:   git config --global init.defaultBranch <name>
hint: 
hint: Names commonly chosen instead of 'master' are 'main', 'trunk' and
hint: 'development'. The just-created branch can be renamed via this command:
hint: 
hint:   git branch -m <name>
Initialized empty Git repository in /project/test/app/.git/
[root@git/project/test/app]# ll .git/
total 16
drwxr-xr-x 2 root root    6 Feb 14 22:41 branches
-rw-r--r-- 1 root root   92 Feb 14 22:41 config
-rw-r--r-- 1 root root   73 Feb 14 22:41 description
-rw-r--r-- 1 root root   23 Feb 14 22:41 HEAD
drwxr-xr-x 2 root root 4096 Feb 14 22:41 hooks
drwxr-xr-x 2 root root   21 Feb 14 22:41 info
drwxr-xr-x 4 root root   30 Feb 14 22:41 objects
drwxr-xr-x 4 root root   31 Feb 14 22:41 refs

#書(shū)寫(xiě)代碼文件
[root@git/project/test/app]# touch live.html
[root@git/project/test/app]# echo "直播功能完成50%" >live.html 
[root@git/project/test/app]# cat live.html 
直播功能完成50%


#查看狀態(tài)
[root@git/project/test/app]# git status
On branch master
No commits yet
Untracked files:
  (use "git add <file>..." to include in what will be committed)
    live.html      #此時(shí)這里為紅色,因?yàn)榇a只存在工作區(qū),沒(méi)有添加到暫存區(qū)
nothing added to commit but untracked files present (use "git add" to track)


#添加到暫存區(qū)
[root@git/project/test/app]# git add .    #這里也可以書(shū)寫(xiě)為git add live.html
[root@git/project/test/app]# git status
On branch master
No commits yet
Changes to be committed:
  (use "git rm --cached <file>..." to unstage)
    new file:   live.html    #綠色表示添加到暫存區(qū)



#提交到本地倉(cāng)庫(kù)
[root@git/project/test/app]# git commit -m "直播50%"
[master (root-commit) ae37f5c] 直播50%
 1 file changed, 1 insertion(+)
 create mode 100644 live.html
[root@git/project/test/app]# git status
On branch master
nothing to commit, working tree clean


#代碼進(jìn)行升級(jí)
[root@git/project/test/app]# vim live.html 
[root@git/project/test/app]# cat live.html
直播功能完成70%
[root@git/project/test/app]# git status
On branch master
Changes not staged for commit:
  (use "git add <file>..." to update what will be committed)
  (use "git restore <file>..." to discard changes in working directory)
    modified:   live.html
no changes added to commit (use "git add" and/or "git commit -a")
[root@git/project/test/app]# git add .
[root@git/project/test/app]# git commit -m "直播70%"
[master 7787f00] 直播70%
 1 file changed, 1 insertion(+), 1 deletion(-)


#查看commit日志(后面回滾用到commit id)
[root@git/project/test/app]# git log
commit 7787f00275ce9353da9af442cf1a9430d9cb9b7d (HEAD -> master)
Author: yunweixiaoyu <xxxx@qq.com>
Date:   Mon Feb 14 23:00:49 2022 +0800
    直播70%
commit ae37f5c6d5b3251f4af4e407292fd7197cf77324
Author: yunweixiaoyu <xxxx@qq.com>
Date:   Mon Feb 14 22:54:38 2022 +0800
    直播50%
[root@git/project/test/app]# git re
rebase         relink         repack         request-pull   revert         
reflog         remote         replace        reset          
[root@git/project/test/app]# git reflog 
7787f00 (HEAD -> master) HEAD@{0}: commit: 直播70%
ae37f5c HEAD@{1}: commit (initial): 直播50%



#回滾(刪除代碼測(cè)試回滾)
[root@git/project/test/app]# rm -rf live.html 
[root@git/project/test/app]# ll
total 0
[root@git/project/test/app]# git reset --hard ae37f5c
HEAD is now at ae37f5c 直播50%
[root@git/project/test/app]# ll
total 4
-rw-r--r-- 1 root root 22 Feb 14 23:06 live.html
[root@git/project/test/app]# cat live.html 
直播功能完成50%
[root@git/project/test/app]# git log
commit ae37f5c6d5b3251f4af4e407292fd7197cf77324 (HEAD -> master)
Author: yunweixiaoyu <xxxx@qq.com>
Date:   Mon Feb 14 22:54:38 2022 +0800
    直播50%        
[root@git/project/test/app]# git reflog 
ae37f5c (HEAD -> master) HEAD@{0}: reset: moving to ae37f5c
7787f00 HEAD@{1}: commit: 直播70%
ae37f5c (HEAD -> master) HEAD@{2}: commit (initial): 直播50%
#注意:當(dāng)回滾到最開(kāi)始的版本的時(shí)候,后面的版本ID號(hào)通過(guò)git log無(wú)法查看,此時(shí)可以使用git reflog進(jìn)行查看,然后進(jìn)行回滾

4.2 Git區(qū)域與狀態(tài)

Git區(qū)域

Git狀態(tài)

4.3 Git命令

命令 含義
git init 初始化本地倉(cāng)庫(kù)目錄
git config --global 郵箱,用戶(hù)名,顏色
git add 提交數(shù)據(jù)到緩沖區(qū)(暫存區(qū)) git add . (所有文件) 或 git add 文件
git commit 把暫存區(qū)的數(shù)據(jù)提交到本地倉(cāng)庫(kù) git commit -m "標(biāo)記/說(shuō)明"
git status 顯示工作空間的狀態(tài)
git reset 回滾
git reset --soft cid(版本號(hào)) 把指定的版本數(shù)據(jù)內(nèi)容下載到暫存區(qū)
git reset HEAD 暫存區(qū)--->工作空間(被修改的狀態(tài))
git checkout 文件下載到工作空間并可以使用 git checkout . 或 git checkout 文件
git reset --hard 版本號(hào)把本地倉(cāng)庫(kù)指定版本信息數(shù)據(jù)下載到工作目錄中

4.4 Git分支

1)什么是分支?

Git分支圖

分支是為了將修改記錄的整體流程分叉保存。分叉后的分支不受其他分支的影響,所以在同一個(gè)遠(yuǎn)程倉(cāng)庫(kù)里可以同時(shí)進(jìn)行多個(gè)修改。分叉后的分支還可以進(jìn)行合并。
默認(rèn)情況下,項(xiàng)目都有一個(gè)主分支master

2)分支案例

#查看項(xiàng)目分支
[root@git/project/test/app]# git branch 
* master

#創(chuàng)建分支
[root@git/project/test/app]# git branch shopping

#切換到shopping分支
[root@git/project/test/app]# git checkout shopping
M   live.html
Switched to branch 'shopping'

#查看當(dāng)前分支
[root@git/project/test/app]# git branch
  master
* shopping

#修改代碼
[root@git/project/test/app]# cat live.html
直播功能完成50%
購(gòu)物功能完成70%

#添加到暫存區(qū),上傳本地倉(cāng)庫(kù)
[root@git/project/test/app]# git add .
[root@git/project/test/app]# git commit -m "購(gòu)物70%"
[shopping 244fb7e] 購(gòu)物70%
 1 file changed, 2 insertions(+), 1 deletion(-)

#此時(shí)在shopping分支上查看代碼內(nèi)容
[root@git/project/test/app]# cat live.html 
直播功能完成50%
購(gòu)物功能完成70%

#切換到master上查看代碼內(nèi)容
[root@git/project/test/app]# git checkout master
Switched to branch 'master'
[root@git/project/test/app]# git branch
* master
  shopping
[root@git/project/test/app]# cat live.html 
直播功能完成70%

#合并分支
[root@git/project/test/app]# git merge shopping -m "直播70%+購(gòu)物70%"
Updating 7787f00..244fb7e
Fast-forward (no commit created; -m option ignored)
 live.html | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
[root@git/project/test/app]# cat live.html 
直播功能完成50%
購(gòu)物功能完成70%

3)臨時(shí)分支(fixbug/hotfix分支)

如果代碼中出現(xiàn)bug,這時(shí)便可以創(chuàng)建分支進(jìn)行修復(fù),修復(fù)完成后進(jìn)行分支的刪除即可

[root@git/project/test/app]# git branch fixbug
[root@git/project/test/app]# git branch
  fixbug
* master
  shopping
[root@git/project/test/app]# git checkout fixbug
Switched to branch 'fixbug'
[root@git/project/test/app]# vim live.html 
[root@git/project/test/app]# cat live.html
直播功能完成50%
購(gòu)物功能完成70%
bug已成功修復(fù)
[root@git/project/test/app]# git add .
[root@git/project/test/app]# git commit -m "bug成功修復(fù)"
[fixbug 0405bc0] bug成功修復(fù)
 1 file changed, 1 insertion(+)
[root@git/project/test/app]# git checkout master
Switched to branch 'master'
[root@git/project/test/app]# git merge fixbug -m "bug修復(fù)完成后與主分支合并"
Updating 244fb7e..0405bc0
Fast-forward (no commit created; -m option ignored)
 live.html | 1 +
 1 file changed, 1 insertion(+)
[root@git/project/test/app]# cat live.html 
直播功能完成50%
購(gòu)物功能完成70%
bug已成功修復(fù)
[root@git/project/test/app]# git branch
  fixbug
* master
  shopping
#修復(fù)并合并后通過(guò)git branch -d 刪除指定分支
[root@git/project/test/app]# git branch -d fixbug
Deleted branch fixbug (was 0405bc0).
[root@git/project/test/app]# git branch
* master
  shopping

4)分支命令匯總

git分支命令 含義
git branch 查看分支
git branch name 創(chuàng)建分支
git branch -d name 刪除分支
git checkout name 切換分支
git merge name 將指定分支合并到當(dāng)前分支
git checkout -b name 創(chuàng)建分支并切換到這個(gè)分支

注意:表中name表示分支名

4.5 tag標(biāo)簽

給commit id設(shè)置別名,也就是標(biāo)簽,相對(duì)方便記憶。

#添加標(biāo)簽(默認(rèn)是對(duì)當(dāng)前最新的commit id進(jìn)行添加)
[root@git/project/test/app]# git tag -a "v1.0" -m "直播和購(gòu)物"
#查看當(dāng)前分支
[root@git/project/test/app]# git tag
v1.0

#對(duì)指定版本的commit id進(jìn)行添加標(biāo)簽(格式如下)
#git tag -a "標(biāo)簽名" -m "描述" commitID
[root@git/project/test/app]# git reflog
0405bc0 (HEAD -> master, tag: v1.0) HEAD@{0}: merge fixbug: Fast-forward (no commit created; -m option ignored)
244fb7e (shopping) HEAD@{1}: checkout: moving from fixbug to master
0405bc0 (HEAD -> master, tag: v1.0) HEAD@{2}: commit: bug成功修復(fù)
244fb7e (shopping) HEAD@{3}: checkout: moving from master to fixbug
244fb7e (shopping) HEAD@{4}: merge shopping: Fast-forward (no commit created; -m option ignored)
7787f00 HEAD@{5}: checkout: moving from shopping to master
244fb7e (shopping) HEAD@{6}: commit: 購(gòu)物70%
7787f00 HEAD@{7}: checkout: moving from master to shopping
7787f00 HEAD@{8}: reset: moving to 7787f00
7787f00 HEAD@{9}: reset: moving to 7787f00
ae37f5c HEAD@{10}: reset: moving to ae37f5c
7787f00 HEAD@{11}: commit: 直播70%
ae37f5c HEAD@{12}: commit (initial): 直播50%
[root@git/project/test/app]# git tag -a "v0.1" -m "直播" ae37f5c
[root@git/project/test/app]# git reflog
0405bc0 (HEAD -> master, tag: v1.0) HEAD@{0}: merge fixbug: Fast-forward (no commit created; -m option ignored)
244fb7e (shopping) HEAD@{1}: checkout: moving from fixbug to master
0405bc0 (HEAD -> master, tag: v1.0) HEAD@{2}: commit: bug成功修復(fù)
244fb7e (shopping) HEAD@{3}: checkout: moving from master to fixbug
244fb7e (shopping) HEAD@{4}: merge shopping: Fast-forward (no commit created; -m option ignored)
7787f00 HEAD@{5}: checkout: moving from shopping to master
244fb7e (shopping) HEAD@{6}: commit: 購(gòu)物70%
7787f00 HEAD@{7}: checkout: moving from master to shopping
7787f00 HEAD@{8}: reset: moving to 7787f00
7787f00 HEAD@{9}: reset: moving to 7787f00
ae37f5c (tag: v0.1) HEAD@{10}: reset: moving to ae37f5c
7787f00 HEAD@{11}: commit: 直播70%
ae37f5c (tag: v0.1) HEAD@{12}: commit (initial): 直播50%

#將標(biāo)簽上傳遠(yuǎn)程倉(cāng)庫(kù)
#這里需要先配置好遠(yuǎn)程倉(cāng)庫(kù)(配置見(jiàn)4.7小節(jié))
git push origin --tags  #上傳所有標(biāo)簽
git push origin "標(biāo)簽名"  #上傳指定標(biāo)簽

生產(chǎn)環(huán)境常用的標(biāo)簽名和含義

1. Alpha     預(yù)覽測(cè)試版
2. Beta      公開(kāi)測(cè)試版
3. RC        最終測(cè)試版
4. Release   正式發(fā)布版本
5. Final     最終版,正式發(fā)布版的一直表示方法
6. Stable    穩(wěn)定版

4.6 gitignore(了解)

上傳代碼的過(guò)程中,代碼目錄中的隱藏文件,里面的內(nèi)容默認(rèn)不會(huì)上傳到遠(yuǎn)程倉(cāng)庫(kù),代碼生成的臨時(shí)文件(需要排除上傳)。
需要排除上傳時(shí),可以在代碼的根目錄創(chuàng)建文件.gitignore書(shū)寫(xiě)需要排除的內(nèi)容即可。
這個(gè)一般是開(kāi)發(fā)人員進(jìn)行書(shū)寫(xiě),這里不做過(guò)多介紹,如果需要可以參考github上的各類(lèi)語(yǔ)言的ignore文件

五、遠(yuǎn)程倉(cāng)庫(kù)gitee

這里我們先簡(jiǎn)單的介紹一下gitee的使用,將本地倉(cāng)庫(kù)上傳至gitee遠(yuǎn)程倉(cāng)庫(kù)中,后續(xù)我們會(huì)搭建開(kāi)源的gitlab作為遠(yuǎn)程倉(cāng)庫(kù)。
使用gitee前我們需要在gitee官網(wǎng)上注冊(cè)gitee賬號(hào),然后進(jìn)行后續(xù)操作。

5.1 gitee上創(chuàng)建倉(cāng)庫(kù)

創(chuàng)建倉(cāng)庫(kù)

創(chuàng)建后會(huì)顯示如下內(nèi)容


image.png

5.2 遠(yuǎn)程連接gitee

#全局配置
git config --global user.name "悠然"
git config --global user.email "xxxx@qq.com"

#因?yàn)楸镜豨it倉(cāng)庫(kù)已經(jīng)創(chuàng)建過(guò)了這里就不重新創(chuàng)建了

#添加遠(yuǎn)程倉(cāng)庫(kù)
[root@git/project/test/app]# git remote add origin https://gitee.com/yunweixiaoyu/app-live.git
#查看遠(yuǎn)程倉(cāng)庫(kù)
[root@git/project/test/app]# git remote -v
origin  https://gitee.com/yunweixiaoyu/app-live.git (fetch)
origin  https://gitee.com/yunweixiaoyu/app-live.git (push)

#上傳本地倉(cāng)庫(kù)內(nèi)容到遠(yuǎn)程倉(cāng)庫(kù)
[root@git/project/test/app]# git push -u origin "master"
Username for 'https://gitee.com': yunweixiaoyu      #gitee賬戶(hù)名
Password for 'https://yunweixiaoyu@gitee.com':      #gitee密碼
Enumerating objects: 12, done.
Counting objects: 100% (12/12), done.
Compressing objects: 100% (5/5), done.
Writing objects: 100% (12/12), 1022 bytes | 1022.00 KiB/s, done.
Total 12 (delta 0), reused 0 (delta 0), pack-reused 0
remote: Powered by GITEE.COM [GNK-6.2]
To https://gitee.com/yunweixiaoyu/app-live.git
 * [new branch]      master -> master
branch 'master' set up to track 'origin/master'.
#上傳tag標(biāo)簽到gitee上
[root@git/project/test/app]# git push origin --tags
Username for 'https://gitee.com': yunweixiaoyu     #gitee賬戶(hù)名
Password for 'https://yunweixiaoyu@gitee.com':     #gitee密碼
Enumerating objects: 2, done.
Counting objects: 100% (2/2), done.
Compressing objects: 100% (2/2), done.
Writing objects: 100% (2/2), 314 bytes | 314.00 KiB/s, done.
Total 2 (delta 0), reused 0 (delta 0), pack-reused 0
remote: Powered by GITEE.COM [GNK-6.2]
To https://gitee.com/yunweixiaoyu/app-live.git
 * [new tag]         v0.1 -> v0.1
 * [new tag]         v1.0 -> v1.0

#下拉代碼到本地倉(cāng)庫(kù)
[root@git/project/test/app]# git pull origin master  #或者git fetch origin master  


#下載代碼到目錄
[root@git/project/test/app]# git clone https://gitee.com/yunweixiaoyu/app-live.git
Cloning into 'app-live'...
Username for 'https://gitee.com': yunweixiaoyu      
Password for 'https://yunweixiaoyu@gitee.com': 
remote: Enumerating objects: 14, done.
remote: Counting objects: 100% (14/14), done.
remote: Compressing objects: 100% (7/7), done.
remote: Total 14 (delta 0), reused 0 (delta 0), pack-reused 0
Receiving objects: 100% (14/14), done.

5.3 配置遠(yuǎn)程倉(cāng)庫(kù)秘鑰認(rèn)證

使用遠(yuǎn)程倉(cāng)庫(kù)gitee的過(guò)程中,我們?cè)谏蟼骱拖吕a都需要輸入用戶(hù)名和密碼,因此我們可以配置秘鑰認(rèn)證進(jìn)行簡(jiǎn)化操作。

1)創(chuàng)建密鑰

#生成密鑰對(duì)
[root@git~]# ssh-keygen 
Generating public/private rsa key pair.
Enter file in which to save the key (/root/.ssh/id_rsa):    #默認(rèn)回車(chē)即可
Created directory '/root/.ssh'.
Enter passphrase (empty for no passphrase):     #默認(rèn)回車(chē)不創(chuàng)建密碼
Enter same passphrase again: 
Your identification has been saved in /root/.ssh/id_rsa.
Your public key has been saved in /root/.ssh/id_rsa.pub.
The key fingerprint is:
SHA256:x6DNxWtF/ObsnwO/GFZT3XNInkbrgj1um56iuPKXwQ4 root@git
The key's randomart image is:
+---[RSA 2048]----+
|           .. o  |
|         . ..+ +o|
|        . o ..*.=|
|       + + = oo +|
|      ..S * ++.o |
|      E oo . ++ .|
|       o o  o+o  |
|    .  .+ ...++o.|
|     o+o.. o=. ++|
+----[SHA256]-----+

#查看公鑰,將內(nèi)容復(fù)制
[root@git~]# cat /root/.ssh/id_rsa.pub
ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQC9xaoi5RVExW1dEQR22XO+sAsEmvuYO/P+NAubeiwDs4ki4xNRdpsXGLn1k+ZAM3z4NP+qzhITWh8HTh5Gje0C+aI/DqnAIFB9LKCRJVeuLtvUazyjKBA3tW1yTXUa3duAWYc4uqdPPB5WvuvHxtwPDpANZY0GMnyZ3Gh1AND2m6RWEMatowkDRxsacGRYi0l4Fg99T/vKg6rvrEoIYDUm2X/L95Qlv5fLVIW0cR5N6oQ5TR8Zizo5s5ZvPgNCQe2zEr3GvBmHRxUwgMMEZywQfHwrLgjSv07/m2HoZywwygZUE5/mOfvlD4RlZ5a+DLbfK6rAVfho1c3iNkXFCW+R root@git

2)公鑰配置到遠(yuǎn)程倉(cāng)庫(kù)

進(jìn)入設(shè)置



按步驟將公鑰復(fù)制即可


3)添加ssh協(xié)議的遠(yuǎn)程倉(cāng)庫(kù)

遠(yuǎn)程倉(cāng)庫(kù)有兩種訪(fǎng)問(wèn)方法

  • https:每次連接都需要輸入賬戶(hù)和密碼
  • ssh:密鑰認(rèn)證,最常用

復(fù)制內(nèi)容


#刪除舊的遠(yuǎn)程倉(cāng)庫(kù),重新配置ssh協(xié)議遠(yuǎn)程倉(cāng)庫(kù)
root@git/project/test/app]# git remote remove origin
[root@git/project/test/app]# git remote add origin git@gitee.com:yunweixiaoyu/app-live.git
[root@git/project/test/app]# git remote -v
origin  git@gitee.com:yunweixiaoyu/app-live.git (fetch)
origin  git@gitee.com:yunweixiaoyu/app-live.git (push)

#測(cè)試
[root@git~]# git clone git@gitee.com:yunweixiaoyu/app-live.git
Cloning into 'app-live'...
The authenticity of host 'gitee.com (180.97.125.228)' 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    #第一次使用需要使用yes確認(rèn)
Warning: Permanently added 'gitee.com,180.97.125.228' (ECDSA) to the list of known hosts.
remote: Enumerating objects: 14, done.
remote: Counting objects: 100% (14/14), done.
remote: Compressing objects: 100% (7/7), done.
remote: Total 14 (delta 0), reused 0 (delta 0), pack-reused 0
Receiving objects: 100% (14/14), done.
最后編輯于
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請(qǐng)聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時(shí)請(qǐng)結(jié)合常識(shí)與多方信息審慎甄別。
平臺(tái)聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀(guān)點(diǎn),簡(jiǎn)書(shū)系信息發(fā)布平臺(tái),僅提供信息存儲(chǔ)服務(wù)。

相關(guān)閱讀更多精彩內(nèi)容

友情鏈接更多精彩內(nèi)容