Working with a free project on GitHub, I forked it, made some changes and asked for a PR, which was accepted.
I upgraded my fork upstream and kept making other changes, then did another PR again.
At that point, I realized that my new PR included all the commits I had already done, and even all the files.
I was supposed to be upstream by now, but either I missed something, or my fork never found out about the accepted PR.
To avoid that, I made a branch with only the modified files. However, the PR for that branch still includes all the commits I've made.
Not so with the files, only the modified one goes.
So what is the correct way to work when one forks a project?
Should I have run any more commands besides upstream? Or do I just have to empty my fork after each PR and go back to work as if it were from scratch?
It sounds like you're going to be collaborating on this project for a long time, not like you want to fix a bug and be gone.
In that case, you can do the following:
master
. In your fork,master
reflect the state of the original project.upstream
that points to the original project, by doinggit remote add upstream https://github.com/ORIGINAL_OWNER/ORIGINAL_REPOSITORY.git
.feature-guau
. You can push calmly, all of that remains in your fork.tufork/feature-guau
aproyecto-original/master
.master
fromupstream
. For that:git checkout master
(that makes you go to work on yourmaster
(which is outdated).git fetch upstream
(that makes your computer "know" what's inupstream/master
, but doesn't make any changes)git reset --hard upstream/master
. That makes yourmaster
worth the same as the master of the original repository. Since your PR was merged, he brought it.git push -f
. That's going to make your fork point to the exact same place as the original project.You can do step 7 at any time, regardless of whether your PR was merged or not... what it does is sync
master
.