How to do it...

For this example, I have forked the Linux Wandboard kernel repository to https://github.com/yoctocookbook2ndedition/linux.git. Refer to the GitHub or source control software documentation for instructions on how to fork a Git repository.

And my recipes-kernel/linux/linux-wandboard_4.1-2.0.x.bbappend file has the following changes:

FILESEXTRAPATHS_prepend := "${THISDIR}/${BP}:" 
WANDBOARD_GITHUB_MIRROR = "git://github.com/yoctocookbook2ndedition/linux.git" 
SRCBRANCH = "4.1-2.0.x-imx-dev" 
SRCREV = "${AUTOREV}" 
COMPATIBLE_MACHINE = "(wandboard|wandboard-custom)" 

Note how the URL needs to start with git://. This is so that BitBake can recognize it as a Git source.

By default, BitBake will use the Git protocol to fetch. Even though GitHub supports the Git protocol, it does not offer it in the clone options in the web page. Cloning with the Git protocol in GitHub is read-only and does not need authentication, which is a good default for a build system.

You can also instruct BitBake to fetch using the HTTPS protocol, which in GitHub is read/write and performs user authentication for writes, by overriding the whole SRC_URI variable in the following way:

FILESEXTRAPATHS_prepend := "${THISDIR}/${BPN}-${PV}:"
WANDBOARD_GITHUB_MIRROR =
"git://github.com/yoctocookbook2ndedition/linux.git"
SRCBRANCH = "4.1-2.0.x-imx-dev"
SRCREV = "${AUTOREV}"
SRC_URI = "${WANDBOARD_GITHUB_MIRROR};protocol=https;branch=$
{SRCBRANCH} \
file://defconfig \
Note that when overriding the whole SRC_URI, we have to remember to include all the variable contents from the original recipe.

Now we can build the Linux kernel and the source will be fetched from the forked repository.