Skip to contents

Clicking on a question will reveal the answer.

How can I prepare a pull request without a clean master branch?

If you want to contribute some of your code to the official mizer code at https://github.com/sizespectrum/mizer you need to first create a branch in your repository that differs from the master branch of sizespectrum/mizer only by the code that you want to contribute, not by any other changes that you may have made in your fork. This answer explains how.

We assume that you have not followed the recommendation of keeping your master branch identical with that at sizespectrum/master, because if you had you could simply follow the procedure described in the “Working with git and GitHub” tutorial. Given that your master branch differs from that at sizespectrum/mizer, you need to create a new branch not from your master branch but directly from that at sizespectrum/master. Follow the following steps:

  1. Go to the “Terminal” tab in RStudio. This should be the tab next to the “Console” tab. If it is not there and you don’t know why not, then you are possibly running an old version of RStudio and you will want to update to a newer version, which is easy from the Help menu under “Check for Updates”.

  2. Make sure you have set the upstream repository correctly. You can check this with the command in the terminal

git remote -v

If that does not list sizespectrum/mizer as the upstream repository for both fetch and push, then you should execute the command

git remote add upstream https://github.com/sizespectrum/mizer.git
  1. Choose a name for your branch. It should be something that indicates the feature you want to implement with the pull request. Then issue the commands
git fetch upstream
git checkout -b name_of_your_branch upstream/master
git push --set-upstream origin name_of_your_branch

where you should replace both name_of_your_branch with the actual name that you
have chosen for you branch.

You now have a new branch that is identical to sizespectrum/master. You can now commit the relevant new code to this branch and create a pull request, as described in the “Working with git and GitHub” tutorial
How can I get a clean master branch?

The recommended way of working in your fork of the mizer project is to keep the master branch of your repository always in sync with the master branch at https://github.com/sizespectrum/mizer, and to create a feature branch for any of your code changes, as is explained in the “Creating a branch” section of the “Working with git and GitHub” tutorial. Note however that having a clean master branch is not a prerequisite to making pull requests, see the answer to “How can I prepare a pull request without a clean master branch?” above.

However if you would like to have a clean master branch, you can follow these steps:

  1. Create a new branch for the content of your current master branch, so that you can still switch to it in the future. To create this new branch, first make sure you have selected the master branch on the “Switch branch” dropdown in RStudio Git panel and then click the button to the left of that dropdown.

In the dialog box enter a name for your new branch and click “Create”.

  1. Go to the “Terminal” tab in RStudio. This should be the tab next to the “Console” tab. If it is not there and you don’t know why not, then you are possibly running a very old version of RStudio and you will want to update to a newer version, which is easy from the Help menu under “Check for Updates”.

  2. Make sure you have set the upstream repository correctly. You can check this with the command in the terminal

git remote -v

If that does not list sizespectrum/mizer as the upstream repository for both fetch and push, then you should execute the command

git remote add upstream https://github.com/sizespectrum/mizer.git
  1. Now issue the following commands in the terminal:
git checkout master
git pull upstream master
git reset --hard upstream/master
git push origin master --force

Now both your local repository and your GitHub repository have the master branch identical to the official master branch. You can now create new feature branches by branching off from this master branch in preparation for submitting pull requests, as explained in the “Working with git and GitHub” tutorial.

You can of course still get at your modified code by switching to the branch you created in the first step above.