gitlab上傳項目需要ssh公鑰免交互,本文介紹gitlab設(shè)置公鑰和上傳項目的操作。
創(chuàng)新互聯(lián)是一家集網(wǎng)站建設(shè),鞏義企業(yè)網(wǎng)站建設(shè),鞏義品牌網(wǎng)站建設(shè),網(wǎng)站定制,鞏義網(wǎng)站建設(shè)報價,網(wǎng)絡(luò)營銷,網(wǎng)絡(luò)優(yōu)化,鞏義網(wǎng)站推廣為一體的創(chuàng)新建站企業(yè),幫助傳統(tǒng)企業(yè)提升企業(yè)形象加強企業(yè)競爭力。可充分滿足這一群體相比中小企業(yè)更為豐富、高端、多元的互聯(lián)網(wǎng)需求。同時我們時刻保持專業(yè)、時尚、前沿,時刻以成就客戶成長自我,堅持不斷學習、思考、沉淀、凈化自己,讓我們?yōu)楦嗟钠髽I(yè)打造出實用型網(wǎng)站。一、創(chuàng)建秘鑰對
[root@localhost ~]# ssh-keygen -t rsa #一路回車即可
二、上傳秘鑰
[root@localhost ~]# cat ~/.ssh/id_rsa.pub #查看公鑰
三、上傳本地代碼
1、要先設(shè)置用戶和郵箱
[root@localhost opt]# git config --global user.name "root"
[root@localhost opt]# git config --global user.email "w135xxxxx@qq.com"
[root@localhost opt]# git config --list
user.name=root
user.email=w135xxxx@qq.com
2、創(chuàng)建一個本地代碼倉庫
[root@localhost opt]# mkdir push_code
[root@localhost opt]# cd push_code/
3、初始化該倉庫
[root@localhost push_code]# git init
初始化空的 Git 版本庫于 /opt/pull_code/.git/
[root@localhost push_code]# echo "this is test push code" > push.txt
[root@localhost push_code]# ls
pull.txt
4、獲取分支
#這個分支信息,可以在web界面clon里看到
[root@localhost push_code]# git remote add origin http://192.168.0.8:81/test/hellow.git
5、刷新遠程倉庫分支
[root@localhost push_code]# git fetch origin --prune
#獲取所有遠程分支
#現(xiàn)在處于master分支
[root@localhost push_code]# git branch -a
0a
master
remotes/origin/devops
remotes/origin/master
6、提交代碼
#提交文件到本地倉庫
[root@localhost push_code]# git add push.txt #添加文件
[root@localhost push_code]# git commit -m "this is test push" #添加說明
[root@localhost push_code]# git push origin master #推送代碼至master分支
#小坑
[root@localhost push_code]# git push origin master
Username for 'http://192.168.0.8:81': root
Password for 'http://root@192.168.0.8:81':
To http://192.168.0.8:81/test/hellow.git
! [rejected] master -> master (non-fast-forward)
error: 無法推送一些引用到 'http://192.168.0.8:81/test/hellow.git'
提示:更新被拒絕,因為您當前分支的最新提交落后于其對應(yīng)的遠程分支。
提示:再次推送前,先與遠程變更合并(如 'git pull')。詳見
提示:'git push --help' 中的 'Note about fast-forwards' 小節(jié)。
#解決:重新拉取遠程代碼倉庫信息,與遠程倉庫代碼信息保持一致
[root@localhost push_code]# git pull http://192.168.0.8:81/test/hellow.git
Username for 'http://192.168.0.8:81': root
Password for 'http://root@192.168.0.8:81':
來自 http://192.168.0.8:81/test/hellow
已經(jīng)是最新的!
7、切換分支
[root@localhost push_code]# git checkout devops
分支 devops 設(shè)置為跟蹤來自 origin 的遠程分支 devops。
切換到一個新分支 'devops'
[root@localhost push_code]# git branch -a
devops
master
remotes/origin/devops
remotes/origin/master
其他分支上傳代碼方式相同重復步驟6即可
8、拉取指定分支代碼
git clone -b devops http://192.168.0.8:81/test/hellow.git #-b指定拉取分支的代碼
9、創(chuàng)建分支
git branch slave 創(chuàng)建slave分支
另外有需要云服務(wù)器可以了解下創(chuàng)新互聯(lián)cdcxhl.cn,海內(nèi)外云服務(wù)器15元起步,三天無理由+7*72小時售后在線,公司持有idc許可證,提供“云服務(wù)器、裸金屬服務(wù)器、高防服務(wù)器、香港服務(wù)器、美國服務(wù)器、虛擬主機、免備案服務(wù)器”等云主機租用服務(wù)以及企業(yè)上云的綜合解決方案,具有“安全穩(wěn)定、簡單易用、服務(wù)可用性高、性價比高”等特點與優(yōu)勢,專為企業(yè)上云打造定制,能夠滿足用戶豐富、多元化的應(yīng)用場景需求。
標題名稱:gitlab上傳公鑰和項目代碼-創(chuàng)新互聯(lián)
URL鏈接:http://muchs.cn/article2/dcjiic.html
成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供標簽優(yōu)化、微信小程序、手機網(wǎng)站建設(shè)、網(wǎng)站設(shè)計公司、關(guān)鍵詞優(yōu)化、網(wǎng)站策劃
聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請盡快告知,我們將會在第一時間刪除。文章觀點不代表本網(wǎng)站立場,如需處理請聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時需注明來源: 創(chuàng)新互聯(lián)