Git Shallow Clone 浅克隆与部分克隆

为什么要用 git clone 默认会把整个历史的所有对象都拉下来。有些场景只需要最新的一份代码,甚至只需要其中一个文件,例如 CI 里构建镜像、流水线里改一行 GitOps manifest 的镜像 tag。这时完整克隆既慢又浪费,网络差的时候还可能超时。 Git 提供了三种互相独立、可以叠加的裁剪方式: 方式 参数 裁掉什么 浅克隆 shallow clone --depth N 历史:只要最近 N 个 commit 部分克隆 partial clone --filter=blob:none 等 文件内容:blob 用到时再按需下载 稀疏检出 sparse checkout --sparse + git sparse-checkout 工作区:只检出指定路径 浅克隆 –depth # only the latest commit git clone --depth 1 https://github.com/foo/bar.git # --depth implies --single-branch; name the branch explicitly git clone --depth 1 --branch main https://github.com/foo/bar.git # by time instead of count git clone --shallow-since=2026-01-01 https://github.com/foo/bar.git --depth 默认带上 --single-branch,只拉一个分支。需要其它分支时,加 --no-single-branch。 ...

Created 2026-10-02 · Updated 2026-10-02 · 2 min · 413 words · -

Tekton 与 Kaniko:云原生 CI/CD 构建实践

Tekton 什么是 Tekton Tekton(发音:/ˈtɛktɒn/,“TEK-ton”)名称来自希腊语 τέκτων,意为"建造者"。 Tekton 是一个开源的云原生 CI/CD 框架,运行在 Kubernetes 上,通过 CRD(自定义资源定义)的方式定义流水线。它是强制 Kubernetes 原生的,所有流水线组件都以 Pod 方式运行,没有其他执行模式。 与 Jenkins、GitLab CI 等工具不同,Tekton 从设计之初就只能运行在 Kubernetes 上,而不是"可选支持 K8s"。这是架构层面的硬性约束,带来的好处是与 K8s 生态深度集成,代价是强依赖 K8s 环境。 Tekton 是 CD Foundation 旗下项目,前身是 Knative 的 Build 模块。 核心概念 Step(步骤) 流水线中的最小执行单元,对应容器中的一条命令。 Task(任务) 由一组有序的 Step 组成,运行在同一个 Pod 中,Steps 共享存储卷。 apiVersion: tekton.dev/v1 kind: Task metadata: name: build-and-push spec: params: - name: image type: string steps: - name: build image: gcr.io/kaniko-project/executor:latest args: - "--dockerfile=$(workspaces.source.path)/Dockerfile" - "--context=$(workspaces.source.path)" - "--destination=$(params.image)" workspaces: - name: source Pipeline(流水线) 由多个 Task 按顺序或并行组成,定义完整的 CI/CD 工作流。 ...

Created 25256-03-25 · Updated 25256-03-25 · 3 min · 551 words · -