To contribute code to a Git repository that you do not have commit access to, you need to create a pull request, asking the owner of the repository to merge your code into the repository. To achieve this cleanly, you should first fork the repository on GitHub and clone this fork to your local machine. Then add an upstream remote so that you can keep track of commits on the original repository. You can do that with the command:

git remote add upstream https://github.com/<username>/<repo name>

Then to update the upstream branches, use the command:

git fetch upstream

Make sure you do this before starting work on a pull request, so you are working with the latest version of the upstream master branch.

The next step is to create a new local branch that contents the code change based on the upstream master branch:

git checkout -b local-branch-name upstream/master

Make your changes and commit them to this local branch. Once that is done, it is time to publish the branch to your GitHub fork:

git push -u origin local-branch-name

You can then create a pull request on the GitHub website. Documentation for this step is here:

Photo by Headway / Unsplash