Gitea官網:https://gitea.io/zh-cn/
Gitea官方文檔:https://docs.gitea.io/zh-cn/
Go-gitea源碼:https://github.com/go-gitea/gitea
gitea-windows下載:https://dl.gitea.io/gitea/1.9/git-1.9-windows-4.0-386.exe
一、安裝
1、在D盤新建文件夾gitea,把剛纔下載的安裝包拷貝到此目錄下,雙擊。
2、註冊爲Windows服務
Win + R 運行cmd,打開命令窗口,輸入如下命令:
# 註冊gitea服務
sc create gitea start= auto binPath= ""D:\gitea\gitea.exe" web --config "D:\gitea\custom\conf\app.ini""
# 刪除gitea服務
sc delete gitea
Win + R 運行 services.msc,可以查看gitea已經添加,右鍵點擊啓動:
3、 訪問
瀏覽器打開http://localhost:3000,默認端口是3000,localhost可以替換成你的ip地址
二、註冊
點擊右上角的註冊,因首次運行,需進行站點初始配置。
1、數據庫設置
注:圖片來源https://www.jianshu.com/p/c6d36e0f72ac
數據庫類型選擇 MySQL 數據庫,沒裝的話,選SQLite3也行,根基自己情況填入本地數據庫參數。
2、一般設置
注:圖片來源https://www.jianshu.com/p/c6d36e0f72ac
SSH服務器域名填入自己本機IP地址,可以在cmd運行ipconfig查看,gitea基本URL記得加上HTTP服務端口號3000。
3、立即安裝
填寫完初始配置,點擊立即安裝,跳轉到登錄界面。
4、註冊賬戶
註冊gitea倉庫登錄賬號。
三、創建gitea倉庫
創建一個名爲gitea_test倉庫,倉庫描述爲:gitea測試
四、本地倉庫git測試
1、HTTP模式測試
- 克隆gitea_test倉庫
$ cd gitea_test
$ git clone http://192.168.1.248:3000/root/gitea_test.git
- 提交文件到gitea_test倉庫
$ cd gitea_test
# 新建txt文件test1
$ touch test1.txt
$ git add test1.txt
$ git commit -m 'test1'
# 查看倉庫
$ git remote remove origin
$ git remote add origin http://192.168.1.248:3000/root/gitea_test.git
$ git remote -v
origin http://192.168.1.248:3000/root/gitea_test.git (fetch)
origin http://192.168.1.248:3000/root/gitea_test.git (push)
# 提交
$ git push origin master
可以看到gitea_test倉庫裏已經有test1.txt文件了
2、SSH模式測試
1、啓用內部SSH服務器
打開gitea.exe的安裝目錄,找到目錄D:\gitea\custom\conf下的app.ini文件,用Notepad++打開,在[server] 的最後添加 START_SSH_SERVER = true 配置,保存退出。
2、生成ssh_key密鑰
ssh-keygen -t rsa -C "郵箱地址"
一路回車,可以看到在C:\Users\自己的用戶名\.ssh文件目錄下 ,生成了id_rsa私鑰和id_rsa.pub公鑰。
3、gitea_test倉庫部署密鑰
將id_rsa.pub公鑰文本複製進去
3、ssh模式測試
- 克隆gitea_test倉庫
$ git clone 自己電腦用戶名@ip地址:22/root/gitea_test.git
成功克隆下來
- 向gitea_test倉庫提交文件test2.txt
$ cd gitea_test
$ touch test2.txt
$ git add .
$ git commit -m 'test2'
$ git push origin master
提交成功:
好了,gitea本地倉庫搭建完成,如有紕漏歡迎留言!
參考來源:https://www.jianshu.com/p/c6d36e0f72ac
https://blog.csdn.net/cr605897869/article/details/80843819