从 Git 到 Fossil
From Git to Fossil

原始链接: https://lucio.albenga.es/web-en/posts/2025/from-git-to-fossil.html

将 Git 仓库迁移至 Fossil 可以通过两步过程实现,相比直接管道传输具有更高的可控性。 首先,使用 `git fast-export --all > ~/git-exported/repository.export` 命令导出 Git 仓库。准备就绪后,使用 `fossil import` 命令将其导入 Fossil: `fossil import --git --rename-master trunk --attribute "email username" repository.fossil ~/git-exported/repository.export` 关键选项说明: * **`--rename-master trunk`**:将 Git 的 "master" 分支重命名为 Fossil 标准的 "trunk" 分支(注意:此操作不适用于 "main" 分支)。 * **`--attribute`**:将 Git 提交记录中的电子邮件映射到特定的 Fossil 用户名。可以使用多个 `--attribute` 标志来处理不同的贡献者。 导入完成后,系统将显示该仓库的项目 ID 以及默认的管理员用户名和密码。请务必保存这些凭据,因为在新的 Fossil 仓库中执行管理任务时需要用到它们。

Hacker News 最近的一场讨论聚焦于博主“smartmic”的一篇文章,文中强烈反对 Git 项目引入 Rust 的举措。作者表示,由于对 Rust 有着本能的排斥,且认为 Rust 社区“极端”并强行要求重写稳定的项目,他决定放弃 Git 转而使用 Fossil。 对此,评论者 WCSTombs 批评这种立场是不理性的。他认为所谓的“Rust 争议”并非真正的问题,并指出 Rust 加入 Git 只是一个微小且务实的技术决策,而非意识形态之争。此外,WCSTombs 澄清道,“强制使用 Rust”仅意味着它对开发者而言是一个构建时的依赖项,对于大多数用户并无强制要求。他强调,尽管有此提议,Git 绝大部分代码依然是用 C 语言编写的,因此他认为原作者的危言耸听纯属“无事生非”。
相关文章

原文

Fossil's documentation has the following example to export a Git repository and import it as a Fossil repository:

cd repository
git fast-export --all | fossil import --git repository.fossil

I did it differently because I wanted to adjust some things to have the imported repositories "right". As I have several repositories I created two different folders, one, git-exported, to store the exported repositories and another one, fossils, to store the new Fossil repositories:

mkdir ~/git-exported
mkdir ~/fossils

Now you can get into each Git repository folder and export it:

cd repository
git fast-export --all > ~/git-exported/repository.export

Once you have exported all your Git repositories you should go inside the ~/fossils folder and import them one by one with the command:

fossil import --git \
       --rename-master trunk \
       --attribute "[email protected] your_username" \
       repository.fossil ~/git-exported/repository.export

The --rename-master trunk option renames your Git master branch as trunk in your new Fossil repository. Fossil, like other version control systems such as Subversion, uses trunk as the name of the master branch. If you are among the unfortunate ones who have their master branch named as "main" this option is not for you and you should check Fossil's documentation if you want to rename it.

The --attribute "[email protected] your_username" option changes the email address "[email protected]" from Git commits to "your_username" in the imported Fossil commits. In Fossil the default username is the same as the one you're currently using in you operating system. Obviously the given email address should exist in one or more commit messages.

If you want to change more than one email address you can do it using several --attribute options:

fossil import --git \
       --rename-master trunk \
       --attribute "[email protected] your_username" \
       --attribute "[email protected] rms" \
       --attribute "[email protected] torvalds" \
       repository.fossil ~/git-exported/repository.export

The output of the import command looks like the following:

Rebuilding repository meta-data...
  100.0% complete...
Vacuuming... ok
project-id: e64b112b40eb3db188060ddb8deeaa96a6ad3b71
server-id:  bfbcd4bf8f0f64eaa2d832ddc3b4af00639624a6
admin-user: your_user (password is "XAxPVZcNQ6")

If you look closely, the output gives you the repository administrator's user and password. Keep it because you'll need it to do certain things on your repository.

联系我们 contact @ memedata.com