環境:
192.168.16.130 git使用節點
192.167.16.145 git本地倉庫
129.28.152.162 雲端gi倉庫
本地節點:
[root@localhost ~]# yum install git
下載git使用
root@localhost ~]# mkdir git_test [root@localhost ~]# ls anaconda-ks.cfg n redis-5.0.0.tar.gz wen git_test n.pub t Mycat-server-1.6-RELEASE-20161028204710-linux.tar.gz redis-5.0.0 w [root@localhost ~]# cd git_test/ [root@localhost git_test]# git init 初始化空的 Git 版本庫於 /root/git_test/.git/ [root@localhost git_test]# ls -a . .. .git
創建並初始化
root@localhost git_test]# touch test [root@localhost git_test]# ls test [root@localhost git_test]# git add . [root@localhost git_test]# git commit -m 'v1' [master(根提交) bc50efc] v1 Committer: root <root@localhost.localdomain> 您的姓名和郵件地址基於登錄名和主機名進行了自動設置。請檢查它們正確 與否。您可以通過下面的命令對其進行明確地設置以免再出現本提示信息: git config --global user.name "Your Name" git config --global user.email you@example.com 設置完畢后,您可以用下面的命令來修正本次提交所使用的用戶身份: git commit --amend --reset-author 1 file changed, 0 insertions(+), 0 deletions(-) create mode 100644 test
touch文件
提交到暫存區
提交到倉庫
root@localhost git_test]# git push -u git@129.28.152.162:root/test.git master
提交到雲端倉庫ssh 免密提交
[root@localhost git_test]# git push -u http://192.168.16.145/root/localhost.git master Username for 'http://192.168.16.145': root Password for 'http://root@192.168.16.145': Counting objects: 6, done. Compressing objects: 100% (3/3), done. Writing objects: 100% (6/6), 454 bytes | 0 bytes/s, done. Total 6 (delta 0), reused 0 (delta 0) To http://192.168.16.145/root/localhost.git * [new branch] master -> master 分支 master 設置為跟蹤來自 http://192.168.16.145/root/localhost.git 的遠程分支 master。
提交到本地145倉庫
雲端配置
rz 上傳 gitlab-ce-8.9.5-ce.0.el7.x86_64
yum install gitlab-ce-8.9.5-ce.0.el7.x86_64.rpm #yum 安裝
vim /etc/gitlab/gitlab.rb 配置文件 external_url 'http://129.28.152.162' 更改為公網ip 地址
gitlab-ctl reconfigure 等待幾分鍾
ss -tnl State Recv-Q Send-Q Local Address:Port Peer Address:Port LISTEN 0 128 127.0.0.1:6379 *:* LISTEN 0 128 127.0.0.1:8080 *:* LISTEN 0 128 *:80 *:* LISTEN 0 128 *:22 *:* LISTEN 0 128 *:10050 *:* LISTEN 129 128 *:10051 *:* LISTEN 0 32 :::21 :::* LISTEN 0 128 :::3000 :::* LISTEN 0 128 :::10050 :::* LISTEN 0 128 :::10051 :::* 查看80 端口啟動 ,沒被http和nginx 占用 我這還有zabbix 的server和agent 在啟動
web 網頁訪問ip
我已經過去了,拿截圖說話吧
登錄
登錄成功
root@localhost git_test]# vim test [root@localhost git_test]# git add . [root@localhost git_test]# git commit -m 'v3' [master 4896692] v3 Committer: root <root@localhost.localdomain> 您的姓名和郵件地址基於登錄名和主機名進行了自動設置。請檢查它們正確 與否。您可以通過下面的命令對其進行明確地設置以免再出現本提示信息: git config --global user.name "Your Name" git config --global user.email you@example.com 設置完畢后,您可以用下面的命令來修正本次提交所使用的用戶身份: git commit --amend --reset-author 1 file changed, 3 insertions(+) [root@localhost git_test]# git push -u git@129.28.152.162:root/test.git master Counting objects: 5, done. Compressing objects: 100% (2/2), done. Writing objects: 100% (3/3), 313 bytes | 0 bytes/s, done. Total 3 (delta 0), reused 0 (delta 0) To git@129.28.152.162:root/test.git 4da5449..4896692 master -> master 分支 master 設置為跟蹤來自 git@129.28.152.162:root/test.git 的遠程分支 master。
編輯測試文件 提交到雲端
雲端完成
本地搭建
rz 上傳 gitlab-ce-8.9.5-ce.0.el7.x86_64 yum install gitlab-ce-8.9.5-ce.0.el7.x86_64.rpm #yum 安裝 vim /etc/gitlab/gitlab.rb 配置文件 external_url 'http://192.168.16.145' 更改為本地 ip 地址
gitlab-ctl reconfigure 初始化使配置生效
創建目錄初始化 mkdir git_test #創建 cd git_test/ #進入 git init #初始化 touch test #創建文件 #可以寫入一些東西 git add . #提交至暫存區 git commit -m 'v3' #提交到倉庫 可以使用本地git目錄 test 提交的時候選擇本地ip git push -u http://192.168.16.145/root/localhost.git master 提交到網絡本地倉庫 輸入賬號密碼 Username for 'http://192.168.16.145': Password for 'http://root@192.168.16.145': Counting objects: 5, done. Compressing objects: 100% (2/2), done. Writing objects: 100% (3/3), 313 bytes | 0 bytes/s, done. Total 3 (delta 0), reused 0 (delta 0) To http://192.168.16.145/root/localhost.git 4da5449..4896692 master -> master 分支 master 設置為跟蹤來自 http://192.168.16.145/root/localhost.git 的遠程分支 master 提交成功
本地成功
ssh秘鑰
ssh-keygen 生成 # cat /root/.ssh/id_rsa.pub 查看復制公鑰
寫入保存