I have almost no clue about git or github and I don't want a clue. But I happen to have a two-line bugfix for an open source project here. In the spirit of cooperation and whatever, I'd like to contribute it back. If it doesn't cost me too much pain.
So, ages ago I forked the repository, then occasionally made a few of my own modifications, and then just recently made this two-line bugfix. Everything has been checked into the master branch and pushed back to origin. Now I want to make a pull request for just the two-line bugfix. It seems github doesn't provide any such facility.
In retrospect, I probably should have made a whole separate project branch before I made my two-line bugfix, but a) that's too much administrative pain for two lines of code and b) I didn't know I'd want to be contributing the bugfix back when I wrote it. And anyway, it's too late now.
I could create a new branch, but that would still contain all the other garbage changes. So it doesn't get me anywhere. I'd like to create a new branch from upstream excluding all my local changes, then redo just this one change. But I can't see any way to do that apart from making a whole new fork, and I don't want a whole new fork.
Right now my best solution is to give up: the code works for me now, it's not my problem. Anyone got a better plan?
The simplest way to do this is to
which gives
git branch my-changes
git stash #just in case you have uncommitted changes
git checkout -b bugfix upstream/master
git cherry-pick <bugfix-commit-sha>
git push --set-upstream origin bugfix
where upstream
is the original forked repo
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With