Windows 10
git version 2.33.1.windows.1
gitea-1.18.3
--
用過一些代碼管理工具:SVN、Gogs、Gitlab,最近聽說了一個叫 Gitea 的,試試。ben發佈於博客園
需提前安裝好 git:
Gitea - Git with a cup of tea
https://gitea.io
Gitea 是一個開源社區驅動的輕量級代碼託管解決方案,後端採用 Go 編寫,採用 MIT 許可證。
本文的 Gitea 使用 SQLite 數據庫(更高級的使用 MySQL、PostgreSQL、TiDB等)。ben發佈於博客園
下載&安裝
點擊菜單欄的“下載”:
下載其中的 gitea-1.18.3-gogit-windows-4.0-amd64.exe (本機CPU架構爲 amd64(x64 也選這個))。
建立 Gitea 根目錄(D:\ws\gitea),將上面的 exe文件拷貝進去,再 雙擊exe 開始安裝:
運行後:選擇【仍要運行】
注意,Windows安裝時會被系統阻止:ben發佈於博客園
訪問默認的 http://localhost:3000/ ,進入 安裝配置頁面:
基本上是默認的即可。
注意,這裏的【管理員賬號設置】不能設置爲 admin——保留名稱:
配置完成後,點擊【立即安裝】,即可安裝完成。ben發佈於博客園
安裝後,增加了一些新的文件及目錄:
其中,custom/conf/app.ini 爲 Gitea 的配置文件。ben發佈於博客園
安裝後,頁面跳轉到登錄頁面:此時,註冊一個新用戶(本文註冊的是 git —— 第一個註冊的賬號即爲 管理員)
不能是 admin:
賬號git 創建成功:
賬號的【管理後臺】:
TODO 需要解決賬號 的頭像問題
創建倉庫
創建倉庫 bootweb:
意外:上圖的倉庫名稱多了一個 【\】,去掉纔可以:ben發佈於博客園
創建成功:
注意,這裏的 主分支爲 main,而不是 之前見過的 master——創建時可以修改。(有什麼歷史緣由嗎?)ben發佈於博客園
使用代碼倉庫
使用 git 命令 拉取代碼並進行一些操作。
複製倉庫的的http連接:
在本地代碼目錄 打開 Git Bash:
拉取:執行 git clone
$ git clone http://localhost:3000/git/bootweb.git
Cloning into 'bootweb'...
remote: Enumerating objects: 4, done.
remote: Counting objects: 100% (4/4), done.
remote: Compressing objects: 100% (3/3), done.
remote: Total 4 (delta 0), reused 0 (delta 0), pack-reused 0
Receiving objects: 100% (4/4), done.
拉取成功:ben發佈於博客園
添加新文件、修改文件、刪除文件:git add, git commit, git push
兩個新文件:
開始操作:
操作記錄
[email protected] MINGW64 /d/ws/gitea/code
$ cd bootweb/
[email protected] MINGW64 /d/ws/gitea/code/bootweb (main)
$ git status -s
?? "file1 - \345\211\257\346\234\254.txt"
?? file1.txt
[email protected] MINGW64 /d/ws/gitea/code/bootweb (main)
$ git add .
[email protected] MINGW64 /d/ws/gitea/code/bootweb (main)
$ git status -s
A "file1 - \345\211\257\346\234\254.txt"
A file1.txt
[email protected] MINGW64 /d/ws/gitea/code/bootweb (main)
$ git commit -m "添加2個文件"
[main 8a32587] 添加2個文件
2 files changed, 2 insertions(+)
create mode 100644 "file1 - \345\211\257\346\234\254.txt"
create mode 100644 file1.txt
[email protected] MINGW64 /d/ws/gitea/code/bootweb (main)
$ git log
commit 8a325879925ed03f32b5366f595c81869a732aa3 (HEAD -> main)
Author: git <[email protected]>
Date: Thu Feb 2 19:06:01 2023 +0800
添加2個文件
commit 63c064611a0e1cd0559922dcc80bad0366836894 (origin/main, origin/HEAD)
Author: git <[email protected]>
Date: Thu Feb 2 18:59:20 2023 +0800
Initial commit
[email protected] MINGW64 /d/ws/gitea/code/bootweb (main)
$ git push origin main
info: detecting host provider for 'http://localhost:3000/'...
info: detecting host provider for 'http://localhost:3000/'...
Enumerating objects: 4, done.
Counting objects: 100% (4/4), done.
Delta compression using up to 8 threads
Compressing objects: 100% (2/2), done.
Writing objects: 100% (3/3), 343 bytes | 343.00 KiB/s, done.
Total 3 (delta 0), reused 0 (delta 0), pack-reused 0
remote: . Processing 1 references
remote: Processed 1 references in total
To http://localhost:3000/git/bootweb.git
63c0646..8a32587 main -> main
[email protected] MINGW64 /d/ws/gitea/code/bootweb (main)
$ git log
commit 8a325879925ed03f32b5366f595c81869a732aa3 (HEAD -> main, origin/main, origin/HEAD)
Author: git <[email protected]>
Date: Thu Feb 2 19:06:01 2023 +0800
添加2個文件
commit 63c064611a0e1cd0559922dcc80bad0366836894
Author: git <[email protected]>
Date: Thu Feb 2 18:59:20 2023 +0800
Initial commit
[email protected] MINGW64 /d/ws/gitea/code/bootweb (main)
$ git add .
[email protected] MINGW64 /d/ws/gitea/code/bootweb (main)
$ git status -s
D "file1 - \345\211\257\346\234\254.txt"
M file1.txt
[email protected] MINGW64 /d/ws/gitea/code/bootweb (main)
$ git commit -m "刪除D、修改文件M"
[main 13c9b32] 刪除D、修改文件M
2 files changed, 2 insertions(+), 2 deletions(-)
delete mode 100644 "file1 - \345\211\257\346\234\254.txt"
[email protected] MINGW64 /d/ws/gitea/code/bootweb (main)
$ git log
commit 13c9b3225ea94fa6ff73cde5846ead08439ba00c (HEAD -> main)
Author: git <[email protected]>
Date: Thu Feb 2 19:07:33 2023 +0800
刪除D、修改文件M
commit 8a325879925ed03f32b5366f595c81869a732aa3 (origin/main, origin/HEAD)
Author: git <[email protected]>
Date: Thu Feb 2 19:06:01 2023 +0800
添加2個文件
commit 63c064611a0e1cd0559922dcc80bad0366836894
Author: git <[email protected]>
Date: Thu Feb 2 18:59:20 2023 +0800
Initial commit
[email protected] MINGW64 /d/ws/gitea/code/bootweb (main)
$ git push origin main
info: detecting host provider for 'http://localhost:3000/'...
info: detecting host provider for 'http://localhost:3000/'...
Enumerating objects: 5, done.
Counting objects: 100% (5/5), done.
Delta compression using up to 8 threads
Compressing objects: 100% (2/2), done.
Writing objects: 100% (3/3), 305 bytes | 305.00 KiB/s, done.
Total 3 (delta 1), reused 0 (delta 0), pack-reused 0
remote: . Processing 1 references
remote: Processed 1 references in total
To http://localhost:3000/git/bootweb.git
8a32587..13c9b32 main -> main
[email protected] MINGW64 /d/ws/gitea/code/bootweb (main)
$ git log
commit 13c9b3225ea94fa6ff73cde5846ead08439ba00c (HEAD -> main, origin/main, origin/HEAD)
Author: git <[email protected]>
Date: Thu Feb 2 19:07:33 2023 +0800
刪除D、修改文件M
commit 8a325879925ed03f32b5366f595c81869a732aa3
Author: git <[email protected]>
Date: Thu Feb 2 19:06:01 2023 +0800
添加2個文件
commit 63c064611a0e1cd0559922dcc80bad0366836894
Author: git <[email protected]>
Date: Thu Feb 2 18:59:20 2023 +0800
Initial commit
[email protected] MINGW64 /d/ws/gitea/code/bootweb (main)
操作後的代碼庫:
注意,這裏已經使用 git config 將 用戶、密碼 等修改了,因此,提交時,無須輸入賬號信息。否則會彈出下面的提示框:ben發佈於博客園
當然,還有配置免密碼操作的方式,暫不清楚。
刪除操作:
ben發佈於博客園
遷移外部倉庫
支持多重外部倉庫的遷移:(本文未測試)
更多操作,後續再慢慢體驗:真香!ben發佈於博客園
聽說還可以和 Jenkins 啥的做集成,還有 Webhook 可以使用,感覺大有可爲啊!
自己用倒沒什麼,要是公司使用的話,還需要考慮哪些方面的問題呢?代碼安全?
---END---
ben發佈於博客園
本文鏈接:
https://www.cnblogs.com/luo630/p/17086804.html
參考資料
1、Gitea 和 Gogs 的關係
https://blog.csdn.net/huyuchengus/article/details/124519103
2、Gitea 的簡單介紹
https://blog.csdn.net/huyuchengus/article/details/124519103
3、windows下使用Jenkins+Gitea持續集成
https://www.cnblogs.com/zhangzimo/p/11101509.html
4、
ben發佈於博客園