Hi,
I’ve been using KiCAD for a few months and I keep having trouble with this. I create a schematic, go to layout and make a layout. I have a board built and have to make changes to the board. I make a new version of the layout and save it with a new name, I usually increment a version number. The problem I have is if I have to go back and change the schematic, the layout has lost its reference to the schematic.
What is the best practice for versioning files? Should I never rename files but use something like git instead?
There is no versioning at all implemented in KiCad itself. Using Git for this is indeed an option that is used commonly. Another way is to archive the (zipped) old project and give it a name of the version.
I usually use a date string in ISO_8601 format both for the “version number”, archiving files and even temporarily renaming files or directories. Such a date string helps me to remember what I did because it tells me when I did it. It’s also almost an UUID you can use as a search string through your file system or documentation.
If your project is damaged somehow, the first thing you should always do is make a backup to prevent worse from happening. It appears you do not have a backup of the old version at all, is that correct?
In KiCad the main schematic sheet should always have the same name as the project. Hierarchical sheets are referenced by filename. Renaming it back is probably enough, and if it is not enough, it should probably still be the first step and other repair actions can be done later.
I create the project within a folder with a descriptive name for the project which I then add to my git.
Once the project is finished and I order the boards ,I create a new folder called “i1” and then copy the git folder contents into it. This becomes my backup and reference of this version.
I can then make changes to the git controlled one and then when that is complete I create an “i2” folder and copy the contents into that, and so on for as many revisions as I order.
This way I have a copy of all my versions for reference and also my working copy on git.
Has worked for me for a number of years.
Sure, it’s possible to work this way, but I suggest you have a closer look at what git is and what it can do. Normally you just create a new branch in the git repository for the newer version. There are also ways to tag certain versions as “special” or whatever you want. And git can do much more. There are thick books written full of what it can do. But it all does add to the complexity. For myself I still backup older versions in zip files, and copy them manually to a backup location. Git has for example also capabilities to (semi) automatically synchronize it’s repository to external devices.
I think it depends on how comfortable you are with git. Creating new folders for each board version encapsulates everything ( hopefully ) that went into that board. It’s easier for someone not familiar with git to open the boards files.
How do you work libraries and library changes into this?
I use git really so I can access kicad files at work or at home, by having the different versions in folders I can open an older version whilst editing my current git version
Basically version the entire project directory rather than the individual files. Renaming the schematic or layout file alone will break the implicit connection between them.
Because merging isn’t usually useful, branches aren’t so useful, either. I have mostly used one branch (master or main) and tags. With tags it’s possible to go back in history. If the design’s history is linear and older versions are needed only occasionally, this is the most simple way to do it. Git branches are good if versions are developed in parallel, although because merging doesn’t work, identical changes must be made as many times as there are development branches.
In my opinion the git history and archives in the file system are two different things and can be handled separately. Different versions can be stored and retrieved from git at any time, but they can also be archived in zip files or just as named folders. What is important to understand has already been said above: KiCad file names must not be versioned, the project folder name can be versioned.