<title>Fossil Quick Start Guide</title>
<h1 align="center">Fossil Quick Start</h1>

<p>This is a guide to help you get started using the Fossil [https://en.wikipedia.org/wiki/Distributed_version_control|Distributed Version Control System] quickly
and painlessly.</p>

<h2 id="install">Installing</h2>

<p>Fossil is a single self-contained C program.  You need to
either download a
[https://fossil-scm.org/home/uv/download.html|precompiled
binary]
or <a href="build.wiki">compile it yourself</a> from sources.
Install Fossil by putting the fossil binary
someplace on your $PATH.</p>
You can test that Fossil is present and working like this:

<blockquote>
<b>
fossil version<br>
<tt>This is fossil version 2.13 [309af345ab] 2020-09-28 04:02:55 UTC</tt><br>
</b>
</blockquote>

<h2 id="workflow" name="fslclone">General Work Flow</h2>

<p>Fossil works with repository files (a database in a single file with the project's
complete history) and with checked-out local trees (the working directory
you use to do your work). 
(See [./whyusefossil.wiki#definitions | definitions] for more background.)
The workflow looks like this:</p>

<ul>
    <li>Create or clone a repository file.  ([/help/init|fossil init] or
        [/help/clone | fossil clone])
    <li>Check out a local tree.  ([/help/open | fossil open])
    <li>Perform operations on the repository (including repository
        configuration).
</ul>

Fossil can be entirely driven from the command line. Many features
can also be conveniently accessed from the build-in web interface.

<p>The following sections give a brief overview of these
operations.</p>

<h2 id="new">Starting A New Project</h2>

<p>To start a new project with fossil create a new empty repository
this way: ([/help/init | more info]) </p>

<blockquote>
<b>fossil init </b><i> repository-filename</i>
</blockquote>

You can name the database anything you like, and you can place it anywhere in the filesystem.
The <tt>.fossil</tt> extension is traditional but only required if you are going to use the 
<tt>[./help?cmd=/server | fossil server DIRECTORY]</tt> feature.”

<h2 id="clone">Cloning An Existing Repository</h2>

<p>Most fossil operations interact with a repository that is on the
local disk drive, not on a remote system.  Hence, before accessing
a remote repository it is necessary to make a local copy of that
repository.  Making a local copy of a remote repository is called
"cloning".</p>

<p>Clone a remote repository as follows: ([/help/clone | more info])</p>

<blockquote>
<b>fossil clone</b> <i>URL  repository-filename</i>
</blockquote>

<p>The <i>URL</i> specifies the fossil repository
you want to clone.  The <i>repository-filename</i> is the new local
filename into which the cloned repository will be written.  For
example, to clone the source code of Fossil itself:

<blockquote>
<b>fossil clone https://fossil-scm.org/ myclone.fossil</b>
</blockquote>

If your logged-in username is 'exampleuser', you should see output something like this:

<blockquote>
<b><tt>
        Round-trips: 8   Artifacts sent: 0  received: 39421<br>
        Clone done, sent: 2424  received: 42965725  ip: 10.10.10.0<br>
        Rebuilding repository meta-data...<br>
        100% complete...<br>
        Extra delta compression... <br>
        Vacuuming the database... <br>
        project-id: 94259BB9F186226D80E49D1FA2DB29F935CCA0333<br>
        server-id:  016595e9043054038a9ea9bc526d7f33f7ac0e42<br>
        admin-user: exampleuser (password is "yoWgDR42iv")><br>
</tt></b>
</blockquote>

<p>If the remote repository requires a login, include a
userid in the URL like this:

<blockquote>
<b>fossil clone https://</b><i>remoteuserid</i><b>@www.example.org/ myclone.fossil</b>
</blockquote>

<p>You will be prompted separately for the password.
 Use [https://en.wikipedia.org/wiki/Percent-encoding#Percent-encoding_reserved_characters|"%HH"] escapes for special characters in the userid.
 For example "/" would be replaced by "%2F" meaning that a userid of "Projects/Budget" would become "Projects%2FBudget") </p>

<p>If you are behind a restrictive firewall, you might need
to <a href="#proxy">specify an HTTP proxy</a>.</p>

<p>A Fossil repository is a single disk file.  Instead of cloning,
you can just make a copy of the repository file (for example, using
"scp").  Note, however, that the repository file contains auxiliary
information above and beyond the versioned files, including some
sensitive information such as password hashes and email addresses.  If you
want to share Fossil repositories directly by copying, consider running the
[/help/scrub|fossil scrub] command to remove sensitive information
before transmitting the file.

<h2 id="import">Importing From Another Version Control System</h2>

<p>Rather than start a new project, or clone an existing Fossil project,
you might prefer to
<a href="./inout.wiki">import an existing Git project</a>
into Fossil using the [/help/import | fossil import] command. 

You can even decide to export your project back into git using the
[/help/git | fossil git] command, which is how the Fossil project maintains
[https://github.com/drhsqlite/fossil-mirror | its public GitHub mirror]. There
is no limit to the number of times a tree can be imported and exported between
Fossil and git.

The [https://git-scm.com/docs/git-fast-export|Git fast-export format] has become
a popular way to move files between version management systems, including from
[https://www.mercurial-scm.org/|Mercurial].
Fossil can also import [https://subversion.apache.org/|Subversion projects] directly.

<h2 id="checkout">Checking Out A Local Tree</h2>

<p>To work on a project in fossil, you need to check out a local
copy of the source tree.  Create the directory you want to be
the root of your tree and cd into that directory.  Then
do this: ([/help/open | more info])</p>

<blockquote>
<b>fossil open </b><i> repository-filename</i>
</blockquote>

for example:

<blockquote>
<b><tt>
    fossil open ../myclone.fossil<br>
    BUILD.txt<br>
    COPYRIGHT-BSD2.txt<br>
    README.md<br>
      ︙<br>
</tt></b>
</blockquote>

(or "fossil open ..\myclone.fossil" on Windows).

<p>This leaves you with the newest version of the tree
checked out.
From anywhere underneath the root of your local tree, you
can type commands like the following to find out the status of
your local tree:</p>

<blockquote>
<b>[/help/info | fossil info]</b><br>
<b>[/help/status | fossil status]</b><br>
<b>[/help/changes | fossil changes]</b><br>
<b>[/help/diff | fossil diff]</b><br>
<b>[/help/timeline | fossil timeline]</b><br>
<b>[/help/ls | fossil ls]</b><br>
<b>[/help/branch | fossil branch]</b><br>
</blockquote>

<p>If you created a new repository using "fossil init" some commands will not
produce much output.</p>

<p>Note that Fossil allows you to make multiple check-outs in
separate directories from the same repository.  This enables you,
for example, to do builds from multiple branches or versions at
the same time without having to generate extra clones.</p>

<p>To switch a checkout between different versions and branches,
use:</p>

<blockquote>
<b>[/help/update | fossil update]</b><br>
<b>[/help/checkout | fossil checkout]</b><br>
</blockquote>

<p>[/help/update | update] honors the "autosync" option and
does a "soft" switch, merging any local changes into the target
version, whereas [/help/checkout | checkout] does not
automatically sync and does a "hard" switch, overwriting local
changes if told to do so.</p>

<h2 id="changes">Making and Committing Changes</h2>

<p>To add new files to your project or remove existing ones, use these
commands:</p>

<blockquote>
<b>[/help/add | fossil add]</b> <i>file...</i><br>
<b>[/help/rm | fossil rm]</b> <i>file...</i><br>
<b>[/help/addremove | fossil addremove]</b> <i>file...</i><br>
</blockquote>

<p>The command:</p>
<blockquote>
<b>
        [/help/changes | fossil changes]</b>
</blockquote>
<p>lists files that have changed since the last commit to the repository. For
example, if you edit the file "README.md":</p>

<blockquote>
<b>
        fossil changes<br>
        EDITED     README.md
</b>
</blockquote>

<p>To see exactly what change was made you can use the command</p>
[/help/diff | fossil diff]:
<blockquote>
<b>
        fossil diff <br><tt>
        Index: README.md<br>
        ============================================================<br>
        --- README.md<br>
        +++ README.md<br>
        @@ -1,5 +1,6 @@<br>
        +Made some changes to the project<br>
        # Original text<br>
 </tt></b>
</blockquote>

<p>"fossil diff" is the difference between your tree on disk now and as the tree was
when you did "fossil open". An open is the first checkout from a repository 
into a new directory. </p>

<p>To commit your changes to a local-only repository:</p>
<blockquote>
<b>
fossil commit     </b><i>(... Fossil will start your editor, if defined)</i><b><br><tt>
# Enter a commit message for this check-in. Lines beginning with # are ignored.<br>
#<br>
# user: exampleuser<br>
# tags: trunk<br>
#<br>
# EDITED     README.md<br>
Edited file to add description of code changes<br>
New_Version: 7b9a416ced4a69a60589dde1aedd1a30fde8eec3528d265dbeed5135530440ab<br>
</tt></b>
</blockquote>

<p>You will be prompted for check-in comments using whatever editor
is specified by your VISUAL or EDITOR environment variable. If none is
specified Fossil uses line-editing in the terminal.</p>

<p>To commit your changes to a repository that was cloned from remote you 
perform the same actions but the results are different. Fossil
defaults to 'autosync' mode, a single-stage commit that sends all changes 
committed to the local repository immediately on to the remote parent repository. This
only works if you have write permission to the remote respository.</p>

<h2 id="naming">Naming of Files, Checkins, and Branches</h2>

<p>Fossil deals with information artifacts. This Quickstart document only deals
with files and collections of files, but be aware there are also tickets, wiki pages and more. 
Every artifact in Fossil has a universally-unique hash id, and may also have a
human-readable name.</p>

<p>The following are all equivalent ways of identifying a Fossil file,
checkin or branch artifact:</p>

<ul>
<li> the full unique SHA-256 hash, such as be836de35a821523beac2e53168e135d5ebd725d7af421e5f736a28e8034673a
<li> an abbreviated hash prefix, such as the first ten characters: be836de35a . This won't be universally unique, but it is usually unique within any one repository. As an example, the [https://fossil-scm.org/home/hash-collisions|Fossil project hash collisions] showed at the time of writing that there are no artifacts with identical first 8 characters
<li> a branch name, such as "special-features" or "juliet-testing". Each branch also has a unique SHA-256 hash
</ul>

<p>A special convenience branch is "trunk", which is Fossil's default branch name for
the first checkin, and the default for any time a branch name is needed but not
specified.</p>

This will get you started on identifying checkins. The
<a href="./checkin_names.wiki">Checkin Names document</a> is a complete reference, including
how timestamps can also be used.

<h2 id="config">Configuring Your Local Repository</h2>

<p>When you create a new repository, either by cloning an existing
project or create a new project of your own, you usually want to do some
local configuration.  This is easily accomplished using the web-server
that is built into fossil.  Start the fossil web server like this:
([/help/ui | more info])</p>

<blockquote>
<b>fossil ui </b><i> repository-filename</i>
</blockquote>

<p>You can omit the <i>repository-filename</i> from the command above
if you are inside a checked-out local tree.</p>

<p>This starts a web server then automatically launches your
web browser and makes it point to this web server.  If your system
has an unusual configuration, fossil might not be able to figure out
how to start your web browser.  In that case, first tell fossil
where to find your web browser using a command like this:</p>

<blockquote>
<b>fossil setting web-browser </b><i>  path-to-web-browser</i>
</blockquote>

<p>By default, fossil does not require a login for HTTP connections
coming in from the IP loopback address 127.0.0.1.  You can, and perhaps
should, change this after you create a few users.</p>

<p>When you are finished configuring, just press Control-C or use
the <b>kill</b> command to shut down the mini-server.</p>

<h2 id="changes">Making Changes</h2>

<p>To add new files to your project, or remove old files, use these
commands:</p>

<blockquote>
<b>[/help/add | fossil add]</b> <i>file...</i><br>
<b>[/help/rm | fossil rm]</b> <i>file...</i><br>
<b>[/help/addremove | fossil addremove]</b> <i>file...</i><br>
</blockquote>

<p>You can also edit files freely.  Once you are ready to commit
your changes, type:</p>

<blockquote>
<b>[/help/commit | fossil commit]</b>
</blockquote>

<p>You will be prompted for check-in comments using whatever editor
is specified by your VISUAL or EDITOR environment variable.</p>

In the default configuration, the [/help/commit|commit]
command will also automatically [/help/push|push] your changes, but that
feature can be disabled.  (More information about
[./concepts.wiki#workflow|autosync] and how to disable it.)
Remember that your coworkers can not see your changes until you
commit and push them.</p>

<h2 id="sharing">Sharing Changes</h2>

<p>When [./concepts.wiki#workflow|autosync] is turned off,
the changes you [/help/commit | commit] are only
on your local repository.
To share those changes with other repositories, do:</p>

<blockquote>
<b>[/help/push | fossil push]</b> <i>URL</i>
</blockquote>

<p>Where <i>URL</i> is the http: URL of the server repository you
want to share your changes with.  If you omit the <i>URL</i> argument,
fossil will use whatever server you most recently synced with.</p>

<p>The [/help/push | push] command only sends your changes to others.  To
Receive changes from others, use [/help/pull | pull].  Or go both ways at
once using [/help/sync | sync]:</p>

<blockquote>
<b>[/help/pull | fossil pull]</b> <i>URL</i><br>
<b>[/help/sync | fossil sync]</b> <i>URL</i>
</blockquote>

<p>When you pull in changes from others, they go into your repository,
not into your checked-out local tree.  To get the changes into your
local tree, use [/help/update | update]:</p>

<blockquote>
<b>[/help/update | fossil update]</b> <i>VERSION</i>
</blockquote>

<p>The <i>VERSION</i> can be the name of a branch or tag or any
abbreviation to the 40-character
artifact identifier for a particular check-in, or it can be a
date/time stamp.  ([./checkin_names.wiki | more info])
If you omit
the <i>VERSION</i>, then fossil moves you to the
latest version of the branch your are currently on.</p>

<p>The default behavior is for [./concepts.wiki#workflow|autosync] to
be turned on.  That means that a [/help/pull|pull] automatically occurs
when you run [/help/update|update] and a [/help/push|push] happens
automatically after you [/help/commit|commit].  So in normal practice,
the push, pull, and sync commands are rarely used.  But it is important
to know about them, all the same.</p>

<blockquote>
<b>[/help/checkout | fossil checkout]</b> <i>VERSION</i>
</blockquote>

<p>Is similar to update except that it does not honor the autosync
setting, nor does it merge in local changes - it prefers to overwrite
them and fails if local changes exist unless the <tt>--force</tt>
flag is used.</p>

<h2 id="branch" name="merge">Branching And Merging</h2>

<p>Use the --branch option to the [/help/commit | commit] command
to start a new branch.  Note that in Fossil, branches are normally
created when you commit, not before you start editing.  You can
use the [/help/branch | branch new] command to create a new branch
before you start editing, if you want, but most people just wait
until they are ready to commit.

To merge two branches back together, first
[/help/update | update] to the branch you want to merge into.
Then do a [/help/merge|merge] of the other branch that you want to incorporate
the changes from.  For example, to merge "featureX" changes into "trunk"
do this:</p>

<blockquote>
<b>fossil [/help/update|update] trunk</b><br>
<b>fossil [/help/merge|merge] featureX</b><br>
<i># make sure the merge didn't break anything...</i><br>
<b>fossil [/help/commit|commit]
</blockquote>

<p>The argument to the [/help/merge|merge] command can be any of the
version identifier forms that work for [/help/update|update].
([./checkin_names.wiki|more info].)
The merge command has options to cherry-pick individual
changes, or to back out individual changes, if you don't want to
do a full merge.</p>

The merge command puts all changes in your working check-out.
No changes are made to the repository.
You must run [/help/commit|commit] separately
to add the merge changes into your repository to make them persistent
and so that your coworkers can see them.
But before you do that, you will normally want to run a few tests
to verify that the merge didn't cause logic breaks in your code.

The same branch can be merged multiple times without trouble. Fossil
automatically keeps up with things and avoids conflicts when doing
multiple merges.  So even if you have merged the featureX branch
into trunk previously, you can do so again and Fossil will automatically
know to pull in only those changes that have occurred since the previous
merge.

<p>If a merge or update doesn't work out (perhaps something breaks or
there are many merge conflicts) then you back up using:</p>

<blockquote>
<b>[/help/undo | fossil undo]</b>
</blockquote>

<p>This will back out the changes that the merge or update made to the
working checkout.  There is also a [/help/redo|redo] command if you undo by
mistake.  Undo and redo only work for changes that have
not yet been checked in using commit and there is only a single
level of undo/redo.</p>


<h2 id="server">Setting Up A Server</h2>

<p>Fossil can act as a stand-alone web server using one of these
commands:</p>

<blockquote>
<b>[/help/server | fossil server]</b> <i>repository-filename</i><br>
<b>[/help/ui | fossil ui]</b> <i>repository-filename</i>
</blockquote>

<p>The <i>repository-filename</i> can be omitted when these commands
are run from within an open check-out, which a particularly useful
shortcut for the <b>fossil ui</b> command.

<p>The <b>ui</b> command is intended for accessing the web interface
from a local desktop.  The <b>ui</b> command binds to the loopback IP
address only (and thus makes the web interface visible only on the
local machine) and it automatically start your web browser pointing at the
server.  For cross-machine collaboration, use the <b>server</b> command,
which binds on all IP addresses and does not try to start a web browser.</p>

<p>Servers are also easily configured as:
<ul>
<li>[./server/any/inetd.md|inetd]
<li>[./server/debian/service.md|systemd]
<li>[./server/any/cgi.md|CGI]
<li>[./server/any/scgi.md|SCGI]
</ul>

<p>The [./selfhost.wiki | self-hosting fossil repositories] use
CGI.

<h2 id="proxy">HTTP Proxies</h2>

<p>If you are behind a restrictive firewall that requires you to use
an HTTP proxy to reach the internet, then you can configure the proxy
in three different ways.  You can tell fossil about your proxy using
a command-line option on commands that use the network,
<b>sync</b>, <b>clone</b>, <b>push</b>, and <b>pull</b>.</p>

<blockquote>
<b>fossil clone </b><i>URL</i>  <b>--proxy</b> <i>Proxy-URL</i>
</blockquote>

<p>It is annoying to have to type in the proxy URL every time you
sync your project, though, so you can make the proxy configuration
persistent using the [/help/setting | setting] command:</p>

<blockquote>
<b>fossil setting proxy </b><i>Proxy-URL</i>
</blockquote>

<p>Or, you can set the "<b>http_proxy</b>" environment variable:</p>

<blockquote>
<b>export http_proxy=</b><i>Proxy-URL</i>
</blockquote>

<p>To stop using the proxy, do:</p>

<blockquote>
<b>fossil setting proxy off</b>
</blockquote>

<p>Or unset the environment variable.  The fossil setting for the
HTTP proxy takes precedence over the environment variable and the
command-line option overrides both.  If you have a persistent
proxy setting that you want to override for a one-time sync, that
is easily done on the command-line.  For example, to sync with
a co-worker's repository on your LAN, you might type:</p>

<blockquote>
<b>fossil sync http://192.168.1.36:8080/ --proxy off</b>
</blockquote>

<h2 id="links">Other Resources</h2>

<ul>
<li> <a href="./gitusers.md">Hints For Users With Prior Git Experience</a>
<li> <a href="./whyusefossil.wiki">Why You Should Use Fossil</a>
<li> <a href="./history.md">The History and Purpose of Fossil</a>
<li> <a href="./branching.wiki">Branching, Forking, and Tagging</a>
<li> <a href="./hints.wiki">Fossil Tips and Usage Hints</a>
<li> <a href="./permutedindex.html">Comprehensive Fossil Doc Index</a>
</ul>
