COMPILE KERNEL FROM SCRATCH
In order to clone the linux raspberry pi repository you have to make a git clone:
$ git clone https://github.com/raspberrypi/linux.git
Then you will have to choose a branch sha-1 number or name:
$ git checkout 20fe468af4bb40fec0f81753da4b20a8bfc259c9
Then you will have to compile the kernel:
$ time make -j 8
MAKE A PATCH
In order to make a patch, first of all you will have to make some modifications. Then you wil have to execute the following command, in order to know which files were modified:
$ git clone https://github.com/raspberrypi/linux.git
$ git checkout 20fe468af4bb40fec0f81753da4b20a8bfc259c9
$ git add files_to_add
$ git status -s
$ git commit -m "Commant with the changes"
$ git show
$ git format-patch 20fe468af4bb40fec0f81753da4b20a8bfc259c9