手工精制的 Git 仓库

There’s no love and care put into crafting our git repositories nowadays.

如今我们在打造 git 仓库时,已经缺乏爱与关怀。

Let’s change that.

让我们改变这一点。

I’m going to talk about how to handmake your git repositories without using these silly git commands.

我将介绍如何在不使用这些愚蠢的 git 命令的情况下手工制作你的 git 仓库。

You might also learn a bit more about how git works under the hood during the process, or whatever.

在这个过程中,你也可能会对 git 的内部机制有更多了解,或者别的什么。

If you’re so inclined, you might also take it as an opportunity to appreciate how the power of git comes not from the complexity of its code but from the simplicity and elegance of its design. I mean, if that’s your thing.

如果你愿意,你也可以把它当作一个机会,去欣赏 git 的力量并非来自其代码的复杂性,而是其设计的简洁与优雅。我是说,如果那是你的菜的话。

Git refers to the user-friendly commands as “porcelain” and to the internals as “plumbing”, so you can think of this as an introductory lesson in git plumbing. In fact, git has “plumbing” commands which we’re not even using, so this is more like an introductory course in git fluid dynamics. In other words, it’s pretty silly.

Git 把用户友好的命令称为 “porcelain”,把内部机制称为 “plumbing”,所以你可以把这当作一堂 git plumbing 的入门课。实际上,git 还有一些我们甚至没用到的 “plumbing” 命令,所以这更像是一门 git 流体动力学的入门课。换句话说,这挺傻的。

Pre-requisites

Pre-requisites

I’m going to assume you are familiar with git and are comfortable in a shell environment, otherwise this probably won’t make much sense to you.

我假设你已经熟悉 git,并且在 shell 环境中游刃有余,否则这些内容可能对你来说意义不大。

Let’s get started

让我们开始吧

The first thing we’d do normally is run git init, but where’s the care and attention in that? We’re going to do it the old-fashioned way, like the pilgrims of yore would’ve done.

通常我们会做的第一件事是运行 git init,但这有什么用心可言呢?我们要用老派的方式来做,就像昔日的朝圣者那样。

# This is where git stores all the information for a repository, from branches to# Git expects these folders to exist, but we don't need to add anything into them yet.$ mkdir -p .git/hooks .git/info .git/objects/info .git/objects/pack .git/refs/heads .git/refs/remotes .git/refs/tags .git/logs# This is just a standard repo-specific config file – these are the default values on my$ cat <<EOF > ....
开通本站会员,查看完整译文。

- 위키
Copyright © 2011-2025 iteam. Current version is 2.146.0. UTC+08:00, 2025-10-20 20:01
浙ICP备14020137号-1 $방문자$