Post date: Mar 1, 2017 7:01:47 AM
本範例暫不使用 ssh
host 網域以 test.tw 表示
host 管理員帳號以 su 表示
local 端網域以 localhost 表示
local 端使用者以 user 表示
在 host 端 安裝 git server 相關套件
su@test.tw# sudo apt-get install git-core
在 host 端 創建 git 使用者帳號(非必要)
su@test.tw# sudo useradd git
su@test.tw# sudo passwd git
以 git 身份在 host 端 建立空白資料夾
git@test.tw$ mkdir project1.git
以 git 身份在 host 端 建立空白 repository
git@test.tw$ cd project1.git
git@test.tw$ git init --bare
======================================
在 local 端 創建空白資料夾與 repository
user@localhost$ mkdir project1
user@localhost$ cd project1
user@localhost:~/project1$ git init
加入檔案準備 push 上自架的 git server
user@localhost:~/project1$ touch test1
user@localhost:~/project1$ git add .
user@localhost:~/project1$ git commit -m "test1" -a
加入完並註解完新檔案後確認是否註解成功
user@localhost$ git log
有看到類似以下訊息即表示註解成功
commit 9b0db3ce32abdd505e56dc03d26c9e2788f200d0
Author: Jyun-Yi Huang <jyunyihuang@gmail.com>
Date: Wed Mar 1 07:30:45 2017 +0100
test1
加入 git server 目的地
user@localhost:~/project1$ git remote add origin git@test.tw:/home/git/project1.git
push 目前狀態至 git server
user@localhost:~/project1$ git push origin master
push 結束之後測試是否能 clone 回 localhost
user@localhost$ git clone git@test.tw:/home/git/project1.git