1

The first time I contribute to an open-source project, I

  • fork the public repository into my own repository
  • make a branch on my own repository
  • make the changes on my own repository
  • create an issue and/or pull request on the public repository
  • wait until it is merged on the public repository

I am now at this point.

To contribute to the same project again, what do I do? (If it matters, I am using GitLab and the public repository is also hosted on GitLab)

I could fork the project again into another repository, but this means I would have many copies of the same repository under my account.

I could set up repository mirroring (GitLab feature that pulls hourly from the public repository into my own repository), but all commits are counted under "My activity" on the graph.

What is the standard procedure to contribute to an open-source project in which I am not a developer in the public project and already have an outdated, forked version?

cccbhsuo
  • 25
  • 5
  • You can update your forked version by raising merge request from original-repo to your-repo, merge that request, this will make your remote repo consistent with original repo, now pull your changes to your local repo by ` git pull origin ` – dkb Dec 31 '18 at 06:49
  • @dkb I tried pressing the "Create merge request" from both my repository and the public one, but they both take me to the same page. From this page, I can only choose the source branch from my repo and the target branch from the public repo. If I continue, it says "Merge from [my repo] into [public repo]". Is this correct? – cccbhsuo Dec 31 '18 at 06:59
  • Check this: https://help.github.com/articles/merging-an-upstream-repository-into-your-fork/ – dkb Dec 31 '18 at 07:04
  • @dkb I'll try that the next time I have another contribution. I was hoping there would be an easy way to do it through the web UI. – cccbhsuo Dec 31 '18 at 07:10
  • Create a new branch in your fork. – Raymond Chen Dec 31 '18 at 11:49
  • @RaymondChen The problem with that is the new branch still does not have the latest commits from the public repo – cccbhsuo Dec 31 '18 at 18:33
  • Then merge the latest commits from the public repo into the new branch. – Raymond Chen Dec 31 '18 at 19:51
  • @RaymondChen Yes, but I do not know how to do that. I am only given an option to merge my repo into the public repo, but not the other way around. – cccbhsuo Jan 01 '19 at 01:16
  • The option from where? Fetch the latest commits in your local repo, make the merge there, push to your own github, and then update the PR. – evolutionxbox Jan 01 '19 at 19:12
  • https://stackoverflow.com/a/48330704/2303202 – max630 Jan 02 '19 at 10:06

1 Answers1

1

You can reuse your fork, since you can update it with the content of "upstream", with "upstream" being the name of the original remote repo (the one you have forked initially)

cd /path/to/your/fork/clone
git add upstream /url/original/repo
git fetch upstream

git checkout -b newBranch upstream/master  
git push -u origin newBranch

You now have a new branch, based on the very latest of upstream/master, from which you can:

  • make new commits
  • push to your fork
  • make a new pull request from said new branch back to the original "upstream" repo.
VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250