When I work on projects, I usually run into the following problem when working with PCB design and code together:

  • I set up a repository using git whose location is at X. This repository contains say, code.
  • I later use a separate design program such as Kicad and start a design project whose location in my computer is at Y.
  • I realize I would like to have my Kicad design files in the repository X for versioning purposes and to synchronize with my team members but I do not feel like changing the current location of my Kicad design directory from Y to X.

Procedure

  • Change working directory to git repository
cd /path/to/git/repo
  • Make an empty bash script file in the current directory named  sync.sh
touch sync.sh
  • Open the file with your fave text editor. I use GNU nano text editor to edit the file
nano kicad_sync.sh

Once the file is open for editing use the

 #Include interpreter path if not in the PATH variable #!/bin/bash #sync any design files that are out of folder source_1="/path/to/external/kicad/folder/Y" dest_1="/path/to/destination/folder/within/this/git/repo/X" mkdir --parents --verbose "$dest_1" cp --recursive --update --interactive --verbose "$source_1"* "$dest_1"

Explanation:

  • #!/bin/bash

    Include the interpreter program if it has not been included in the PATH environment variable.

  • source_1="/path/to/external/kicad/folder/Y"

    Stores the kicad source folder path into variable source_1

  • dest_1="/path/to/destination/folder/within/this/git/repo/X"

    Stores the destination folder path into variable dest_1

  • mkdir --parents --verbose "$dest_1"

The line above creates the directories including the parents if they do not exist. Example: ./design/Kicad may be a non-existent directory in the git folder but the command creates the parent folder /design/ first if it doesnt exist, then creates the folder KIcad after that.

cp --recursive --update --interactive --verbose "$source_1"* "$dest_1"

copy from source_1 all files and folders recursively to dest_1 only if they are updated/new and query  interactively.

  • Save and close the bash script file.
  • Now anytime I would make changes to the PCB design and I would like to put those changes in the git project all I have to do is:
    sh kicad_sync.sh

    The file in the git folder is now updated and I can now then continue with my normal git workflow. Remember to add the local kicad project folder to the staging area then commit.

Leave a Reply

Please log in using one of these methods to post your comment:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s