Linux: Git
- TAGS: Linux
使用
指定ssh密钥文件
git_addr='[email protected]:group1/ops.git' tmp_path='~/.jasper/jenkinsfile' git config core.sshCommand "ssh -i ${tmp_path}/id_rsa" #更换key git clone -c "core.sshCommand=ssh -i ${tmp_path}/id_rsa" $git_addr #克隆指定
协议替换
git config --global url."https://".insteadOf git://
git 服务器
stagit-静态Git页面生成器
stagit是一个用C语言编写的工具,专门用于生成Git仓库的静态HTML页面。通过简单的命令行操作,用户可以轻松地为任意Git仓库创建一个静态网站,这对于需要快速部署和展示代码库的场景尤为有用。
stagit的核心技术基于C语言和libgit2库。它利用libgit2的强大功能来解析和处理Git仓库的数据,然后生成相应的HTML文件。
参考:
安装 stagit 工具
# linux sudo apt update sudo apt install -y gcc make sudo apt install -y libgit2-dev git clone git://git.codemadness.org/stagit cd stagit/ make ss -tnlp sudo make install man stagit
创建工作目录
# 创建一个工作目录git-source,子目录 git-source/{htmldir,repos} # htmldir 存储构建相关脚本,repos 存放 git 源码库 cd ~/ mkdir -pv git-source/git-source/{htmldir,repos} # 将 stagit 的 example_create.sh 和 example_post-receive.sh 到 htmldir 里 cp stagit/example_create.sh stagit/example_post-receive.sh git-source/htmldir/ # 将 reposdir 的值设置为包含您的 Git 存储库的 绝对路径 vim git-source/htmldir/example_create.sh reposdir="/home/jasperhsu/git-source/repos" chmod +x git-source/htmldir/example_create.sh # html 相关 # 将 stagit 的 style.css 复制到 git-source 目录。后期可以自己调整。 # 将您站点的 Logo 和 Favicon 图片复制到 git-source 目录下。文件名不要修改 cp stagit/{style.css, favicon.png,logo.png} git-source/ # 将你的代码库或者别人的代码库存储在 repos 里 git clone https://github.com/bbatsov/prelude.git git-source/repos/prelude
Git 存储库里面的 owner 和 description 是特殊文件,用于单独显示每个存储库的所有者名称和描述,直接写入纯文本内容即可。下面是两个 Git 存储库的示例
~/git-source$ tree -L 2 . ├── favicon.png ├── htmldir │ ├── example_create.sh # 生成多个 Git 存储库静态页面的脚本 │ └── example_post-receive.sh # Git 的 post-receive hook 脚本,暂且按下不表 ├── logo.png ├── repos # 包含您的 Git 存储库 │ ├── prelude # 存储库一,内容已省略 │ └── xvo.es # 存储库二,示例内容如下 │ ├── 404.html │ ├── LICENSE # 存储库许可证 │ ├── owner # 存储库所有者名称 │ ├── README.md # 存储库说明 │ ├── _redirects │ ├── description # 存储库描述 │ ├── index.html │ ├── lists.html │ └── vercel.json └── style.css
生成静态页面
cd git-source/ ./htmldir/example_create.sh # http服务 python3 -m http.server --directory=./
生成的网页可以托管到任意的静态托管服务上,如 GitHub Pages、Cloudflare Pages 等。
cgit
cgit 是一个用 C 编写的用于 Git 存储库的超高速前端用户界面,特点:简单、强大。谁在使用?比如: https://git.kernel.org/ https://cgit.git.savannah.gnu.org/cgit/emacs.git/
参考