GIT Examples

    • Sign up for github if you haven’t already
    • Fork the Firmware (see )
    • Clone your forked repository to your local computer
    • Go into the new directory, initialize and update the submodules, and add the original upstream Firmware
      1. git submodule update --init --recursive
      2. git remote add upstream https://github.com/PX4/Firmware.git
    • This can be checked with the following command:
      1. git remote -v
    • Make the changes that you want to add to the current master.
    • Create a new branch with a meaningful name that represents your feature
      1. git checkout -b <your feature branch name>
      you can use the command git branch to make sure you’re on the right branch.
    • Add your changes that you want to be part of the commit by adding the respective files
      1. git add <file name>
      If you prefer having a GUI to add your files see Gitk or .
    • Commit the added files with a meaningful message explaining your changes
      1. git commit -m "<your commit message>"
      For a good commit message, please refer to Contributing section.
    • Some time might have passed and the has changed. PX4 prefers a linear commit history and uses git rebase. To include the newest changes from upstream in your local branch, switch to your master branch
      Then pull the newest commits from upstream master
      1. git pull upstream master
      Now your local master is up to date. Switch back to your feature branch
      and rebase on your updated master
      1. git rebase master
    • Now you can push your local commits to your forked repository
      1. git push origin <your feature branch name>
    • Now it’s time to create a pull request (PR). On the right hand side of the “new branch message” (see one step before), you should see a green button saying “Compare & Create Pull Request”. Then it should list your changes and you can (must) add a meaningful title (in case of a one commit PR, it’s usually the commit message) and message (explain what you did for what reason. Check for comparison)
    • You’re done! Responsible members of PX4 will now have a look at your contribution and decide if they want to integrate it. Check if they have questions on your changes every once in a while.

    There are several ways to update a submodule. Either you clone the repository or you go in the submodule directory and follow the same procedure as in Contributing code to PX4.

    This is required after you have done a PR for a submodule X repository and the bug-fix / feature-add is in the current master of submodule X. Since the Firmware still points to a commit before your update, a submodule pull request is required such that the submodule used by the Firmware points to the newest commit.

    1. cd Firmware
    • Make a new branch that describes the fix / feature for the submodule update:
    • Go to submodule subdirectory
      1. cd <path to submodule>
    • PX4 submodule might not necessarily point to the newest commit. Therefore, first checkout master and pull the newest upstream code.
      1. git checkout master
      2. git pull origin master
    • Go back to Firmware directory, and as usual add, commit and push the changes.
      1. cd -
      2. git add <path to submodule>
      3. git push upstream pr-some-fix
    1. git fetch upstream pull/<PR ID>/head:<branch name>

    PR ID is the number right next to the PR’s title (without the #) and the <branch name> can also be found right below the PR ID, e.g. <the other persons git name>:<branch name>. After that you can see the newly created branch locally with

      Then switch to that branch

      1. git push --force-with-lease origin <your feature branch name>

      If a conflict occurs during a git rebase, please refer to .

      If a conflict occurs during a , please refer to this guide.