Git (and Python) workflow when contributing to the official KiCad libraries

Jump to navigation Jump to search

This description of the Git (and Python) workflow when contributing to the official KiCad libraries is intended as a simple walk-through how-to for users new to KiCad and Git but who have enough know-how to open a terminal and use the command line.

Contributing to KiCad

Instead of effort being wasted by any number of different designers recreating their own versions of symbols, footprints or 3d models of unknown quality, by contributing to the official libraries, the combined effort will help these to grow benefiting all KiCad users.[1]

The KLC

The KiCad Library Convention (KLC) is a set of requirements for contributing to the official KiCad libraries.[2]

The things that are really important still need to be hand checked. This is the main work that library maintainers do. For example the pin numbers, names and types still needs to be compared to the datasheet, for footprints a dimension check is also required.[1]

KiCad utilities

Before making a pull request use the KiCad utilities (Python scripts) to check whether the parts you are considering submitting are KLC compliant. They mainly check stuff that is only important for having a consistent library.[1]

Travis CI

On GitHub Travis CI checks KLC compliance of footprint files and symbol libraries.

Usage

See the README.md file. Run these in a terminal window using Python

Use pcb/check_kicad_mod.py to check KLC compliance of footprint files.

Use schlib/checklib.py to check KLC compliance of schematic symbol libraries.

GitHub (out of date, now hosted at GitLab)

GitHub simply hosts a Git server and provides a nice web interface.[3] The official KiCad libraries are hosted on GitHub.

One time SSH key setup

Create a fork (e.g. footprints)

At https://github.com/KiCad/kicad-footprints click Fork at the top right, to fork your own copy of KiCad/kicad-footprints to your GitHub account.[4]

Note that https://github.com/KiCad/kicad-footprints is referred to as "upstream" and your fork https://github.com/YOUR-USERNAME/kicad-footprints as "origin".[5]

Git Bash

To go to your home directory, enter with no other text

cd

To list the files and folders in your current directory, enter

ls

To go into one of your listed directories, enter

cd your_listed_directory

To go up one directory, enter

cd ..

[4]

Git

Git is an open source distributed version control system (VCS) and is available for multiple OS. It is available for free.[6][7][8]

The command line is the only place you can run all Git commands, most of the GUIs implement only a partial subset of Git functionality for simplicity. If you know how to run the command-line version, you can probably also figure out how to run the GUI version, while the opposite is not necessarily true.[9]

Initial setup

The first thing to do is to set your user name and email address, every Git commit will use this information. Use the git config command with the --global option this only needs to be done once:[10][11]

To setup the user name

git config --global user.name "John Smith"

To setup the user email address

git config --global user.email john@example.com

To check the user name

git config user.name

To check the user email address

git config user.email

Usage (e.g. for footprints)

For help on common Git commands, enter:

git --help

For the manual page on a particular command, (e.g. add) enter:

git --help add

To have the files in your fork on your computer, create a clone of your fork locally on your computer with:

git clone https://github.com/YOUR-USERNAME/kicad-footprints

The commands below are done in the folder of your working copy of the fork (# marks a comment).

To update:

git pull

Add the official KiCad repo as another remote. This takes care of keeping all branches up-to-date between your downstream repository or fork ("origin") and the KiCad repo ("upstream"). This only needs to be done once:[10][12]

git remote add upstream https://github.com/KiCad/kicad-footprints.git

Make a separate pull request (PR) for each separate library, (e.g. Button_Switch_THT.pretty vs. Potentiometer_THT.pretty). To do this you need to have one branch per contribution:

git fetch upstream # get the state of the official repo
git checkout upstream/master # change to the current head of the official repo
git checkout -b new_sensible_branch_name # create a new branch from that state
git push --set-upstream origin new_sensible_branch_name # push that new branch to github

Make your changes then:

git add --all # or git add list_of_files
git commit -m "descriptive_commit_message"
git push # push your changes online

Go to https://github.com/YOUR-USERNAME/kicad-footprints and click the "Compare & pull request" button to do the PR. Complete the form and click "Create pull request".

If you then are requested to do some changes you would need to checkout the correct branch and then do your changes:

git checkout branch_connected_to_pull_request # without -b switch

Do your changes:

git add --all # or again git add file_list
git commit -m "descriptive_commit_message"
git push # push your fixes to GitHub (will automatically appear in the pull request)

[3][13]

To keep your fork current with the upstream repository:[12]

$ git merge upstream/master

Further reading

  • Pro Git by Scott Chacon, Ben Straub Paperback, Apress, Nov. 2014, ISBN 9781484200773

References

External links

KiCad

Tutorials

Python

Git

Tutorials

Github

Tutorials