Fossil SCM

fossil-scm / www / inout.wiki
1
<title>Import And Export</title>
2
3
Fossil has the ability to import and export repositories from and to
4
[http://git-scm.com/ | Git]. And since most other version control
5
systems will also import/export from Git, that means that you can
6
import/export a Fossil repository to most version control systems using
7
Git as an intermediary.
8
9
<h2>Git → Fossil</h2>
10
11
To import a Git repository into Fossil, say something like:
12
13
<pre>
14
cd git-repo
15
git fast-export --all | fossil import --git new-repo.fossil
16
</pre>
17
18
The 3rd argument to the "fossil import"
19
command is the name of a new Fossil repository that is created to hold the Git
20
content.
21
22
The --git option is not actually required. The git-fast-export file format
23
is currently the only VCS interchange format that Fossil understands. But
24
future versions of Fossil might be enhanced to understand other VCS
25
interchange formats, and so for compatibility, use of the
26
--git option is recommended.
27
28
<a id="fx_git"></a>
29
Note that in new imports, Fossil defaults to using the email component of the
30
Git <em>committer</em> (or <em>author</em> if <code>--use-author</code> is
31
passed) to attribute check-ins in the imported repository. Alternatively, the
32
[/help/import | <code>--attribute</code>] option can be passed to have all
33
commits by a given committer attributed to a desired username. This will create
34
and populate the new <code>fx_git</code> table in the repository database to
35
maintain a record of correspondent usernames and email addresses that can be
36
used in subsequent exports or incremental imports.
37
38
<h3>Converting Repositories on Windows</h3>
39
40
The above commands work best on proper POSIX systems like Linux, macOS,
41
and the BSDs, where everything <tt>git</tt> sends is consumed by
42
<tt>fossil</tt> as soon as it can manage, with both programs working
43
concurrently.
44
45
Historically, PowerShell indiscriminately sent objects — as opposed to raw
46
bytes — through its pipes, and buffered standard input for external processes.
47
This made it choke on the conversion when the in-flight repository size
48
exceeded available memory. Starting with version 7.4 (2023-11-16), PowerShell
49
supports byte stream piping between native commands and file redirection.
50
51
If you are stuck with an older version, one workaround is to fall back to
52
<tt>cmd.exe</tt> — which doesn't seem to be affected by this problem.
53
Nevertheless, we instead recommend using
54
Microsoft's own [https://learn.microsoft.com/en-us/windows/wsl/ | Windows
55
Subsystem for Linux] or either of the two popular "Git for Windows"
56
distributions based on MSYS2. They handle pipes the POSIX way, avoiding
57
any dependency on the amount of data involved.
58
59
<h2>Fossil → Git</h2>
60
61
To convert a Fossil repository into a Git repository, run commands like
62
this:
63
64
<pre>
65
git init new-repo
66
cd new-repo
67
fossil export --git ../repo.fossil | git fast-import
68
</pre>
69
70
In other words, create a new Git repository, then pipe the output from the
71
"fossil export --git" command into the "git fast-import" command.
72
73
Note that the "fossil export --git" command only exports the versioned files.
74
Tickets and wiki and events are not exported, since Git does not understand
75
those concepts.
76
77
As with the "import" command, the --git option is not required
78
since the git-fast-export file format is currently the only VCS interchange
79
format that Fossil will generate. However,
80
future versions of Fossil might add the ability to generate other
81
VCS interchange formats, and so for compatibility, the use of the --git
82
option is recommended.
83
84
<h2>Mirror A Fossil Repository In Git</h2>
85
86
Fossil version 2.9 and later supports a simple mechanism for
87
doing a Git or
88
[./mirrortogithub.md|GitHub mirror of a Fossil repository].
89
See that separate document for details. Fossil is self-hosting,
90
but a [https://github.com/drhsqlite/fossil-mirror|GitHub mirror of Fossil]
91
is available as a proof-of-concept.
92
93
<h2>Bidirectional Synchronization</h2>
94
Fossil also has the ability to synchronize with a Git repository via repeated
95
imports and/or exports. To do this, it uses marks files to store a record of
96
artifacts which are known by both Git and Fossil to exist at a given point in
97
time.
98
99
To illustrate, consider the example of a remote Fossil repository that a
100
user wants to import into a local Git repository. First, the user would clone
101
the remote repository and import it into a new Git repository:
102
103
<pre>
104
fossil clone /path/to/remote/repo.fossil repo.fossil
105
mkdir repo
106
cd repo
107
fossil open ../repo.fossil
108
mkdir ../repo.git
109
cd ../repo.git
110
git init .
111
fossil export --git --export-marks ../repo/fossil.marks \
112
../repo.fossil | git fast-import \
113
--export-marks=../repo/git.marks
114
</pre>
115
116
Once the import has completed, the user would need to <tt>git checkout
117
trunk</tt>. At any point after this, new changes can be imported from the
118
remote Fossil repository:
119
120
<pre>
121
cd ../repo
122
fossil pull
123
cd ../repo.git
124
fossil export --git --import-marks ../repo/fossil.marks \
125
--export-marks ../repo/fossil.marks \
126
../repo.fossil | git fast-import \
127
--import-marks=../repo/git.marks \
128
--export-marks=../repo/git.marks
129
</pre>
130
131
Changes in the Git repository can be exported to the Fossil repository and then
132
pushed to the remote:
133
134
<pre>
135
git fast-export --import-marks=../repo/git.marks \
136
--export-marks=../repo/git.marks --all | fossil import --git \
137
--incremental --import-marks ../repo/fossil.marks \
138
--export-marks ../repo/fossil.marks ../repo.fossil
139
cd ../repo
140
fossil push
141
</pre>
142

Keyboard Shortcuts

Open search /
Next entry (timeline) j
Previous entry (timeline) k
Open focused entry Enter
Show this help ?
Toggle theme Top nav button