sag
sag

Reputation: 5451

Creating new fork without affecting existing fork

I forked a github repository and did many changes to the master branch. There are many changes that are specific to my requirement and if I submit a pull request for all the changes, it will not be accepted by the original owner of the repository as many changes are specific to my requirement.

But I need to submit some of the features which may be accepted and will be useful for other users as well. So now I want to create a new fork though I already have a forked repository in my account. And I don't want to affect the existing fork.

In the new fork I can add the specific changes and create a pull request with that.

How can I accomplish it?

Upvotes: 0

Views: 73

Answers (1)

ljrk
ljrk

Reputation: 811

No need for a new fork!

You do not pull-request from fork F to original O but from a branch a of F to branch b of O!

You create a new branch (eg. "PRQ_feature-you-added") that's at the same level as the original repo and then reapply the changes you did and want to share onto this branch.
Then you make a pull request from this branch to the one in the original repo.

This is actually in line with general good-practice: Always create a new branch for a pull request.

Code:
others_username is the username of the one holding the original repository you want to contribute to.
their_branch is the branch of that repo you want to pull-request to, usually it's the default master.
$COMMIT_ID is the id of the commit you want to share. Possibly there are merge-conflicts you need to solve, though.
Also you might want to use rebase instead of cherry-pick, depending on how and what you commited.
origin is the internal remote-name . reference of your repository, it could be different but if you directly cloned it, that's the default.

git remote add other_repo github.com/others_username/project_name
git fetch other_repo
git checkout -b PRQ_new-feature other_repo/their_branch
git cherry-pick $COMMIT_ID
git push --set-upstream origin PRQ_new-feature

In the Webinterface create a pull request from your branch.

But you should definitely read up on how git (not GitHub) branches and forks work.
I like "thinklikeagit" (just google).

Upvotes: 3

Related Questions