Building app with nRF Connect SDK in Private Repo

In this blog, I would like to describe how to fork the Nordic nRF Connect SDK or Zephyr on your own github and then how to sync with the original stream.

I have refer to some webpage post about this such as

Guideline from Zephyr Project

One general practice we encourage, is to make small, controlled changes. This practice simplifies review, makes merging and rebasing easier, and keeps the change history clear and clean.

When contributing to the Zephyr Project, it is also important you provide as much information as you can about your change, update appropriate documentation, and test your changes thoroughly before submitting.

The general GitHub workflow used by Zephyr developers uses a combination of command line Git commands and browser interaction with GitHub. As it is with Git, there are multiple ways of getting a task done. We’ll describe a typical workflow here:

How to fork the zephyr repository on the own github (if you haven’t forked the repository)

Step 1:

Visit the github (zephyr)

https://github.com/zephyrproject-rtos/zephyr

Create a Fork of Zephyr to your personal account on GitHub. (Click on the fork button in the top right corner of the Zephyr project repo page in GitHub.)

Step 2:

After you fork the repository, the zephyr would be showed at your github.

How to clone the zephyr version and set the remote upstream.

Step 1:

git clone the zephyr project at the local PC.

https://docs.zephyrproject.org/latest/getting_started/index.html

west init -m https://github.com/jimmywong2003/zephyr
cd zephyr
west update

Step 2 :

Add the remote repository with zephyr origin

On your development computer, change into the zephyr folder that was created when you obtained the code:

cd zephyrproject/zephyr

Rename the default remote pointing to the upstream repository from origin to upstream:

git remote rename origin upstream

Let Git know about the fork you just created, naming it origin:

git remote add origin https://github.com/<your github id>/zephyr

and verify the remote repos:

git remote -v

The output should look similar to:

origin   https://github.com/<your github id>/zephyr (fetch)
origin   https://github.com/<your github id>/zephyr (push)
upstream https://github.com/zephyrproject-rtos/zephyr (fetch)
upstream https://github.com/zephyrproject-rtos/zephyr (push)

You can ‘git push’ to get the changes up to your github.

git push --set-upstream origin <name_of_your_branch>

When there comes some new updates from upstream you can get those by:

cd zephyr
git checkout master
git fetch upstream
git merge upstream/master

Clone the nRF Connect SDK

Step 1:

Create a Fork of NRF Connect SDK to your personal account on GitHub. (Click on the fork button in the top right corner of the Zephyr project repo page in GitHub.)

Fork the nrf repository

After fork, the git repository of sdk-nrf would be present at your own github

Step 2:

Initialize west and clone the nRF Connect SDK manifest repository nrf:

cd <sourcecode_root>
mkdir ncs
cd ncs
west init -m https://github.com/jimmywong2003/sdk-nrf
west update
west zephyr-export

Step 3:

On your development computer, change into the nrf folder that was created when you obtained the code:

cd ncs/nrf

Let Git know about the fork you just created, naming it origin:

git remote add upstream https://github.com/nrfconnect/sdk-nrf

and verify the remote repos:

git remote -v

The output should look similar to:

origin https://github.com/jimmywong2003/sdk-nrf (fetch)
origin https://github.com/jimmywong2003/sdk-nrf (push)
upstream https://github.com/nrfconnect/sdk-nrf (fetch)
upstream https://github.com/nrfconnect/sdk-nrf (push)

Checkout the Git version (tag)

After clone the repository, the default is using the master branch.

git status

List out all the tags from the repository

git tag

Checkout the particular version such as v1.3.0

git checkout v1.3.0

Switch back to master branch

You can use the Git GUI tool (such as Git Extensions)

Sync with upstream to origin repository

After from time to time, the upstream repository has some difference push request from other developer. It would have difference from the upstream repository.

In order to sync with origin and upstream repositoory, it needs to do the fetch and the merge at the origin.

Fetch with upstream repository

Merge with origin/master

After sync with upstream, the master , origin/master and upstream/master are using the same entry point.

After push back to the git,

You would see the github branch to sync with nrfconnect:master.


Additional information:

Also this git guide is short and simple: https://rogerdudler.github.io/git-guide/

Adding the Contribution Guidelines for Zephyr.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

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

Google photo

You are commenting using your Google 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 )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.