Reputation: 5301
I have this situation. I forked a repo from github. I made some changes in a separate branch locally. Then merged it with master. Then i pushed it to my github repo. I also send the pull request.
Somebody made changes in a file on the main repo. I want to fetch it and make changes in that file. I want to send its pull request separately.
How do i start from my local repo ?
Upvotes: 1
Views: 2355
Reputation: 1323343
I made some changes in a separate branch locally. Then merged it with master
Don't: you should make a pull request from the branch which isn't present in the upstream repo you have forked.
That way, you can keep master
always in sync with the master
of the upstream (original) repo.
See "a couple of tips on pull requests" for more.
That means:
I forked a repo from github. I made some changes in a separate branch locally
Push that branch, and make your pull request from that branch (with a target: upstream repo/master
)
You can then pull from upstream to update your master (which you never touch: you just add commits from the upstream repo to your local clone, and push master to your fork to keep it up-to-date).
Then you can rebase your local branch on top of the updated master, check that everything is still working, and push --force to your fork that branch.
The magic is: your existing pull request will automatically be updated with your new commits from that branch you just forced push.
In details:
cd /local/path/to/your/clone
git remote add upstream https://github.com/user/original_repo
git fetch upstream
git checkout master
# reset master to upstream master
git reset --hard upstream/master
git checkout yourBranch
git rebase master
# check that everything works
git push -f origin master
git push -f origin yourBranch
# Make your pull request from your branch in your fork on GitHub
Once that is done, future evolutions to your patch mean:
# update master with upstream master new commits
git checkout master
git pull upstream master
# rebase your local branch
git checkout YourBranch
git rebase master
# check that everything still works
git push origin master
git push origin yourBranch
# your pull request will AUTOMATICALLY BE UPDATED!
# nothing to do on GitHub
Upvotes: 3