Skip to content
Andrea Tagliasacchi edited this page May 22, 2020 · 13 revisions

How to contribute

Step by step instructions that will guide you through the code contribution process. We will be using ataiya as an example GitHub username here, as it will allow us to show some "live" examples of pull requests. Further information is also available here.

Fork the tensorflow_graphics repository on GitHub

fork

Clone your fork locally

~/: git clone https://github.com/ataiya/graphics.git ~/tfg
~/: cd ~/tfg

Note you can use SSH authentication as well.

Setup upstream branch of your repo

You will want to keep your fork up-to-date with the main codebase. To do so, we will add an official remote:

~/tfg: git remote add official https://github.com/tensorflow/graphics.git

You can inspect the remotes you will be using:

~/tfg: git remote -v
official	https://github.com/tensorflow/graphics.git (fetch)
official	https://github.com/tensorflow/graphics.git (push)
origin	        https://github.com/ataiya/graphics.git (fetch)
origin	        https://github.com/ataiya/graphics.git (push)

Create a contribution branch

If you are planning to make multiple isolated contributions, it is a good idea to use different branches, one per contributions you plan to perform. You can do so via git commands:


~/tfg: git checkout -b contribution1
Switched to a new branch 'contribution1'
~/tfg: git fetch official
~/tfg: git reset --hard official/master
~/tfg: git push -u origin contribution1
Branch 'contribution1' set up to track remote branch 'contribution1' from 'origin'.
~/tfg: git branch
* contribution1
  master

The published branch is now visible https://github.com/ataiya/graphics/tree/contribution1.

  • Note: The fetch and reset git commands ensure this branch's history is just a copy of the "official" repo.
  • Note: You could omit git push -u if you only wanted local branch, but we will need it to be public to be able to create a pull request.

Keeping your branch up to date

You will want to update your branch often with the (master branch of the) official repo to minimize the chance of conflicts, or at least make them easier/faster to resolve:

~/tfg: git pull official master
 * branch            master     -> FETCH_HEAD
Already up to date.

As we just forked the official repository, our branch is already up to date.

Make changes and publish them to your branch/fork

~/tfg: echo "Simple test change" >> simple_test_change.txt
~/tfg: git add simple_test_change.txt
~/tfg: git commit -m "A simple test change"
~/tfg: git push

And now our simple "A simple test change" is visible on the public fork: https://github.com/ataiya/graphics/commit/75422103e1c3ac5a8a460c23d19d18c7440c861e

Creating a pull request

We can now visit the branches page of your fork https://github.com/ataiya/graphics/branches and create a pull request against tensorflow_graphics as we show in the image below

Clone this wiki locally