# Upgrading and Changing your Project Settings There are several ways to update your Pegasus project. These methods can be used to upgrade your project to a new Pegasus version, or when changing anything in your project configuration. ## Using the Github integration (recommended) The easiest way to upgrade your project is to use the built-in Github integration. If you created your project with Github, you should be able to make any changes you want to your project configuration and then create a pull request with the updated code from the "Download" page. If you did not create your project with the Github you can still use this method. First follow the instructions for [connecting an existing project to Github](github.md#connecting-an-existing-project-to-github). After completing that step, you should be able to submit updates to your project via pull request, just like above. You can watch a demo of this set up here:
## Manually, using branches If you don't want to, or can't, use the Github integration, you can manually upgrade your project with git branches. Note that this is a longer and more complicated process than using the Github integration, which handles most of these steps for you. With this option you maintain a "pure" Pegasus branch in your repository with no other modifications. Then, you merge this branch into your main app when you upgrade. This process is outlined below, and also in the below screencast which shows a live example on a real Pegasus project. Here are the steps to take: ### 1. Create a branch for the upgrade First [checkout the first commit](https://stackoverflow.com/questions/43197105/how-do-you-jump-to-the-first-commit-in-git) in your repository and create a new branch from there. After finding and checking out the initial commit, run: ``` git branch pegasus git checkout pegasus ``` *Note: if you created the `pegasus` branch when you set up your codebase you can skip this step. Alternatively, if you don't have any commit with pure pegasus code, see the instructions at the bottom of this page to create one.* Next, make sure the branch is up-to-date with your current Pegasus version: 1. Download your Pegasus project on your *current* version and unzip the code. 2. Copy the `.git` folder from your main project into the downloaded codebase. 3. Make sure you are on the `pegasus` branch (`git checkout pegasus`) 4. Commit all changes (`git add .` then `git commit -am "ready to upgrade"`) ### 2. Upgrade the code in the branch 1. Upgrade your project on saaspegasus.com 2. Download the latest codebase and unzip the code. 3. Copy the `.git` folder from step 1 into this new folder. 4. Commit all changes (`git add .` then `git commit -am "upgrade to latest Pegasus"`) ### 3. Merge into your main branch 1. Checkout the (latest/current) main branch (`git checkout main`) 2. Merge the code (`git merge pegasus`) Alternatively you may wish to do this in a new branch and then submit a pull request to the main branch from there: 1. Create a new branch off of the main branch (`git checkout main; git checkout -b upgrade-pegasus`) 2. Merge the code (`git merge pegasus`) In the merging step you should look at the modifications being made, and you may have to manually resolve conflicts that come up. You may also need to run `./manage.py makemigrations` to create any database migrations that were not included with Pegasus. ## Manually, using patches (if you can't use Github or branches) You can also follow a similar process to the above using Git patches. Patches do not require working in the same repository or having a previously created branch. At a high level you will: 1. Create a patch file containing the changes in the upgrade. 2. Apply the patch to your app. Here we'll walk through the steps in more detail. ### 1. Creating the patch file Follow these steps to create your patch file: 1. Download a "clean" version of your Pegasus project on your *current* version, and commit it to a git branch or repository. 2. Upgrade your Pegasus version (or change your configuration), and download the new codebase. 3. Copy your `.git` directory from your "clean" project in step 1 into your new project in step 2. E.g. `cp -r path/to/yourapp/.git path/to/newapp/`. 4. In your new project directory, *commit all of the changes* in a single commit. 5. Create a patchfile for the commit using [git-format-patch](https://git-scm.com/docs/git-format-patch). The recommended command to run is `git format-patch -1 HEAD`. You should now see a file in your repository root with a name like `0001-branch-details.patch`. This is your patch file. ### 2. Applying the patch file Now return to your main branch in your application's repository. First, use [git-apply](https://git-scm.com/docs/git-apply) to apply the patch. The recommended command to run is: ``` git apply --ignore-space-change --ignore-whitespace --reject /path/to/