1

I am very new to github which I am using with rstudio. I have forked a repo, made branches and merged them back in to the master branch for the forked repo. How then do I merge the changes from the forked master branch back in to the original repo?

I though I had to issue a pull request from the fork but all I am presented with in the forked repo is that the master branch is the default branch. The other branches all have buttons associated with them that allow me to create a new pull request but not the master.

Am I thinking about this the wrong way? How do I get my master branch integrated in to the original repo?

Sebastian Zeki
  • 6,690
  • 11
  • 60
  • 125
  • You may want to look at this question which explains it: https://stackoverflow.com/questions/7244321/how-do-i-update-a-github-forked-repository – Dominik Wosiński Apr 11 '19 at 12:28
  • This might help: https://help.github.com/en/articles/creating-a-pull-request – Pan Long Apr 11 '19 at 12:30
  • @DominikWosiński So given I had already done git remote add upstream (and have checked that the original repo is in the upstream with git remote -v I guess I had already set this up? OK now I understand... – Sebastian Zeki Apr 11 '19 at 12:34

1 Answers1

0

The workflow you're looking for goes something like this:

  1. Make changes on the local copy of your forked repo, on a feature branch.
  2. Push that feature branch to the forked remote on Github.
  3. Visit the forked repo on Github; Github will prompt you to open a pull request from your forked feature branch to the upstream repo.
  4. Open the PR, get it merged.
  5. Update your fork with the changes from upstream (these commands run from the the root directory of your local fork):
$ git fetch upstream
$ git merge upstream/master
$ git push

By pushing your changes to your forked master, it's diverging history from the upstream. Most of the time (such as in OSS contribution), the upstream is the 'source of truth' and has the final say about what goes on both of the master branches.

Jake Worth
  • 5,490
  • 1
  • 25
  • 35