How to reference Source Code
Put the link where your readers will find it most easily, i.e. as early in the document as possible. A link to your repository in the introduction would be ideal. Placing an identical reference elsewhere in your paper wouldn't hurt - nothing is worse than having to hunt through a paper just to find the single github link.

Similarly, the exact format should be conducive to finding your code, so a direct link is likely easier to follow. A formal reference may work better if you reference the repository several times within the manuscript.