_posts/2020-12-06-fossil-to-git.md (view raw)
1---
2title: fossil export to git
3author: la-ninpre
4tags: [fossil, git, tutorial]
5---
6
7i was trying to export my website repo to fossil using suggested method from
8[fossil website][1]:
9
10```
11git fast-export --all | fossil import --git repo.fossil
12```
13[1]:https://www.fossil-scm.org/home/doc/trunk/www/inout.wiki
14
15but i didn't like that fossil recognizes my email as username and so commit
16messages user was `user@example.com` instead of `user`.
17
18i then read a bit about options of `git fast-export` and found `--anonymize`
19flag. but it's results weren't satisfying either.
20
21when i looked on a raw output of `git fast-export`, i noticed that commit author
22is specified there as
23
24```
25author user <user@example.com>
26```
27
28and then it's flashed in my head: why not pipe git export through sed and just
29replace the contents of `<>` with username instead of email.
30
31so the final command looks like this:
32
33```
34git fast-export --all | \
35 sed -E 's/^((author)|(committer))[[:blank:]]+([[:graph:]]+)[[:blank:]]+(<[[:alnum:]]+@[[:alnum:]]+\.[[:alnum:]]+>)/\1 \4 <\4>/' | \
36 fossil import --git repo.fossil
37```
38
39and it converts
40
41```
42author user <user@example.com>
43```
44
45to
46
47```
48author user <user>
49```
50
51which is odd, but fine for fossil import.