Search code examples
version-controlfossil

fossil: add files to existing repo, do I need to open first?


I wish to control versions of a directory, let's call it "project", and keep the fossil files inside another directory named "fossils." I have successfuly created the "project.fsl" repository, added my project files, committed, and closed. My problem is understanding how to take the next step.

Here is what I do, following the fossilbook suggestions.

$ cd project
$ fossil new ../fossils/project.fsl
$ fossil open ../fossils/project.fsl
$ fossil add .
$ fossil ci -m "first commit"
$ fossil close project.fsl

Now I have worked on my project, edited some files, deleted some files, created some files, renamed some files. I'd like to add the current state of the project to the repository. How do I do that?

Based on what I read in the doc, I was under the impression I had to first open the repository, then add files, then commit. If I don't open the repository, I get the Not within an open checkout. message. But if I open fossil wants to overwrite my directory with the older files. (And if I open from within the fossils directory, I get an "unpacked" version of my project copied into the fossils directory, not what I want either)

$ cd project
$ fossil open ../fossils/project.fsl

Here fossil wants to overwrite my project with the older version. I say no to every suggestion. I suspect open was not the correct approach, but then if not what is?

I want to add my changes to the repository, so now that project.fsl is open, I try this:

$ fossil add .
 ADDED  Slides/tmp.tex

$ fossil commit -m "no idea what I'm doing, this will not end well"
 would fork.  "update" first or use --allow-fork.

$ fossil close
 there are unsaved changes in the current checkout

At this point I delete all the hidden files named .fslckout .fossil and try again, with similarly disappointing results.

To be quite frank, my only interest in fossil is keeping a history of my project. I have no co-authors and don't plan to do fossil diff or fossil ui or anything like that until such a time, which I hope will never happen, when I need to dig into the history of my project.

Edit. I am a total newbie. I not sure I understand the meanings of checkout, manifest, leaf, etc. so it's making it very hard for me to get anything out of the manual, notwithstanding the countless hours spent trying. I don't understand much of this page on fossil open: http://fossil-scm.org/fossil/help/open


Solution

  • fossil open is the right thing to do. In your case, it's the fossil close that wasn't necessary.

    At this point, you should do fossil open ../fossils/project.fsl --keep to open your repo while keeping all the changes.

    The open command marks the current directory as a work directory (in Fossil terms, a checkout). I recommend you do not close it until you need to move either your repo or the working directory itself. Personally, that only happens when I move to a different computer.

    To have fossil identify all changes, just do fossil addremove; fossil will then add all new files, and remove all deleted files, so that the repository once more matches the working directory. Of course, you still have to commit the changes afterward.

    Note that addremove does not automatically recognise file renames! If you've renamed files, you should let Fossil know this for each file using the fossil rename command, before you perform the addremove command. Of course, if you don’t mind breaking the edit history of specific files, you're free to skip that, and let fossil think one file was deleted and another added instead.