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.