Reputation: 8617
I forked a GitHub project into my own repository. My repository contains only a "master" branch in which I commit my own code. The forked project contains a "master" branch only as well.
From time to time, I find and fix some bug in the original code and I want to create a pull request so that the developers of the original project can add the fix. However, I don't want to add to this pull request all the code I changed, just the fix.
I think the correct way to proceed here is to create a new branch in my repository, synchronize this with the original forked master, commit the fix and create the pull request. My question is: how can I create a branch and get rid of all my commits to synchronize it with the forked master?
As an aside, is this actually the most practical way of doing this?
Upvotes: 0
Views: 162
Reputation: 1663
I can suggest next steps for solving your problem:
git remote add upstream <url_to_forked_project>;
git fetch upstream;
git checkout upstream/master -b fix;
git cherry-pick <commit_hash>;
or make a new commit somehow
git push origin fix:fix;
git branch -d fix;
- remove the unused branch
Upvotes: 1
Reputation: 2512
You can create a branch and revert all the commits using git revert command that you want to get rid of.
And then sync forked repository to get all the changes done in the upstream repository.
Upvotes: 2