Let’s say a repo named cool-stuff is on github.
I have a fork of cool-stuff and I have submitted a PR associated with my fork of cool-stuff which is waiting to be merged.

Now, there is another independent fork of cool-stuff,say, even-cooler-stuff which works on new features to introduce to cool-stuff. I would like to contribute to the even-cooler-stuff repo but github won’t let me since I already have a fork of cool-stuff.

Is there any way to do what I want like this or should I manually tell the author of even-cooler-stuff the changes I want to do?

  • Lodra@programming.dev
    link
    fedilink
    English
    arrow-up
    9
    ·
    1 year ago

    Create a new branch on your fork. You need it to be synced with the other fork so there are a few extra tricky steps. On your new branch, you need to delete the latest commits that aren’t merged yet so that it matches the original repo. Then add a remote for the other fork and pull. Now you can build against the other fork and submit a PR to it.

    git checkout -b even-cooler-stuff
    # Remove the last 8 commits. Change this number as needed. Increasing it "too high" is just fine 
    git reset HEAD~8 --hard
    git remote add even-cooler-stuff https://github.com/more-of-url/even-cooler-stuff
    git pull even-cooler-stuff
    

    You should now have a branch that matches the other fork. Make your changes, commit, and push normally. When you build the PR, you want to merge into the other fork.

    Disclaimer: I wrote this on my phone and from memory. There are probably typos and possibly other mistakes. Good luck!