Setup for Pull Requests

From GnuCash
Revision as of 04:36, 4 June 2023 by Dawansv (talk | contribs) (small adjustment in presentation)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search

This page gives instructions on setting up your local development environment to use Git, a Github personal account, and your local computer to create Pull Requests (PRs) for updates to GnuCash.

Overview

Submitting changes to GnuCash using PRs involves three pieces:

  1. The GnuCash repository
  2. Your own Github fork of the main GnuCash repository
  3. Your own local copy, which is a copy of your Github repository.

Your forked copy of the GnuCash repository is what will allow you to publish your proposed changes to Github. By adding this extra repository into the process, you can create branches locally and commit them to your Github copy. From your Github repository, you will then have the option to issue a PR to the main GnuCash repository, which the developers can then approve and commit to the final project. This eliminates the need to create patches.

Having your own Github fork requires you to have a Github account, so sign up for one if you haven't got one already and set it up for ssh access.

Note
If you are using Eclipse, the EGit User_Guide Remote of the Eclipse Wiki is useful. It explains also key generation and related steps.

Set-Up Your Personal Fork of the Gnucash Repository

Use Github's fork feature to set up a your own personal read-write enabled clone on GitHub:

  1. In a web browser, go to Github, login and search for Gnucash.
  2. Click on the link for the required repository, e.g.
    Gnucash/gnucash or
    Gnucash/gnucash-docs
  3. Click on the Fork button at top right. This will create
    www.github.com/[YOUR-GITHUB-USERNAME]/gnucash or
    www.github.com/[YOUR-GITHUB-USERNAME]/gnucash-docs

Set-Up a Local Repository on your PC

As you will eventually push your modified local repository branch back to your personal GitHub fork created in the previous step, it is useful to create your local git repository (on your PC) by cloning from that GitHub fork repository, rather than the official GnuCash repository. The remote name origin in your local git repository, is automatically set up to point to where you clone from (in this case your Github fork of the gnucash repository).

  1. Create the directory you wish to hold your repository or repositories in and make it current. Assuming you wish it to be called github in your home directory:
    mkdir ~/github
    cd ~/github
    
  2. Clone from your remote personal repository origin:
    git clone git@github.com:<YOUR-GITHUB-USERNAME>/gnucash.git
    
    The clone example above will
    1. create the local repository ~/github/gnucash,
    2. define a remote named origin pointing to your Github fork of the gnucash repository which you can use in future as a shortcut instead of the full URL,
    3. check out the default stable branch
  3. Change into the repository directory:
    cd gnucash
    
  4. Verify that you are now on the stable branch:
    git branch
    
    should output
      * stable
    
  5. See An_Introduction_to_Git#Pull_Requests for more information on how to create a new branch for your changes, push it to your fork and create your pull request.


Technical Note: Suggested repository names for Non-Committers Using Pull Requests

Use the following names in your local PC repository for remote repositories:

upstream
The official GnuCash repository to which only authorized developers can write, e.g.
github.com/Gnucash/gnucash or
github.com/Gnucash/gnucash-docs
These are public mirrors for the real GnuCash official repositories.
origin
This is your personal writable GitHub repository, e.g.
github.com/[YOUR-GITHUB-USERNAME]/gnucash or
github.com/[YOUR-GITHUB-USERNAME]/gnucash-docs
Pull requests are made from here to the upstream repository.
Background
origin is the default remote for git push, so it is less typing.
Note
Developers with write access often use a different association:
remote name URL
origin github.com/Gnucash/*
upstream code.gnucash.org/*
mygh github.com/ME/*