Question

I forked a public Github repository, cloned the fork to a local repo, made some changes, pushed them to the master branch of my fork. Then I opened a pull request and it was merged into the original repo.

Now I want to make next changes. I do them locally, push to the master branch of my fork and try to open another pull request. Github shows both the new changes and the previously merged changes as belonging to this new pull request. Clearly I only want the new changes listed.

What am I doing wrong and how do I do it right?

Was it helpful?

Solution

pushed them to the master branch of my fork

This can makes your next pull request hard to merge. What you should do now is

git checkout master
git pull --rebase upstream master

where upstream is the "original" repo, to get your master branch in line with its master. The rebase may take manual editing. Now, to submit a pull request, branch off master:

git checkout -b new-branch
# edit edit edit
git push origin new-branch

and submit a pull request from your new branch. This way, your master branch stays in sync with the original repo's.

If you still have commits in your master that are not in upstream's master, make sure you put those in a separate branch, then git reset --hard the master branch.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top