# Setting up a Local Development Environment
In order to work on the HPR codebase, first of all create your
account, as explained in [developer information](developer_information.md).

## Create your local environment
The next step is to create your development environment locally:
1. Fork the HPR repository you want to work on. Do this by clicking
   the Fork button top right in the repository header:
   
   ![repository header](assets/images/repository-header.png)
   
2. Go to your terminal on your computer, and clone the HPR repository
   locally:
   ```` 
   $ git clone gitea@repo.anhonesthost.net:HPR/hpr_documentation.git
   ````
   It doesn't matter if you use the ssh or http link for the code -
   you don't have write access to the main repository, so you won't be
   pushing code back there.
3. Change to the clone repository - you will now see the remote listed
   as origin:
   ````
   $ cd hpr_documentation
   $ git remote -v
   origin	gitea@repo.anhonesthost.net:HPR/hpr_documentation.git (fetch)
   origin	gitea@repo.anhonesthost.net:HPR/hpr_documentation.git (push)
   ````
4. Create a remote for your fork of the repository:
   ````
   $ git remote add upstream gitea@repo.anhonesthost.net:[YOUR_USER]/hpr_documentation.git
   $ git remote -v
   origin	gitea@repo.anhonesthost.net:HPR/hpr_documentation.git (fetch)
   origin	gitea@repo.anhonesthost.net:HPR/hpr_documentation.git (push)
   upstream	gitea@repo.anhonesthost.net:[YOUR_USER]/hpr_documentation.git (fetch)
   upstream	gitea@repo.anhonesthost.net:[YOUR_USER]/hpr_documentation.git (push)
   ````

You now have a repository you can keep up to date with the main repo,
and also work on making additions.

## Making code changes
1. In order to make changes, the first step is to update your local
   repository:
   ````
   $ git checkout main    # In case you are still in a branch from an earlier change
   $ git pull origin
   ````
2. Create a branch to work on the changes:
   ````
   $ git checkout -b adding-developer-setup-information
   ````
3. Make the changes
4. Check the changes work! You don't want to push broken code upstream!
5. Commit your changes locally
   ````
   $ git add *
   $ git commit 
   ````
   Note - the commit message should have the issue number at the
   beginning. So in this case, "Issue #6 - Document how to create local
   environment". Note - Depending on the editor you are using to
   edit your commit message, you might have issues if you *start*
   the message with a '#'.
6. Push the changes to **your** repository:
   ````
   $ git push upstream
   ````
7. Go to your repository online - you will now see an option to create
   a pull request against the main HPR repository. Click the Create
   **Pull Request** button and fill out the form.

8. Once the pull request is accepted, you can delete your local branch
   if you wish.

## Summary
Using this approach means contributing is straight forward, and
doesn't require everyone to have write access to the main HPR
repositories.  Since you are pulling from the origin repositories, you
will always be working on up to date code.
