INTRODUCTION
I've forked a repository that follows the so-called "git flow" and has to develop/master/factory branches. I'll reference from now on my fork as origin and the main repository as upstream.
After opening an issue and talk/agree on few things with the repo maintainer I started working on it. The first thing I did was creating a feature branch tracking (origin/develop).
After few temporary commits with temporary throw-away temporary bad names, I'd created a PR and pushed. The idea I had in mind was eventually squashing all my commits on a single one and then providing a proper commit name/description so the maintainer would be able to merge all of it to upstream/develop without any problems, my main goal was making the whole process as smooth as possible both for me and the upstream maintainer, once merged I'd happily delete my local branch, job done, easy peasy... :)
PROBLEM
I was naive thinking that would go so smoothly!
I'm not a git expert by any means and I was wrong thinking the PR would evolve so smoothly (this tend to happen when you don't know really the tools you're using). At a certain point, I'd stopped working on my PR for few days and obviously upstream/develop continued evolving and getting far away ahead of my PR, my PR wasn't passing the tests yet and the whole PR was still pending unfinished job.
A few days later I decided to come back to that PR and tried to resume my work, after fetching upstream/develop I'd seen many upstream commits were already far away ahead from my PR and I didn't really know what was the best choice on that particular situation, I didn't know and I still don't know whether merging or rebasing is the best choice...
With little knowledge about the possible implications about merging or rebasing I decided merge couldn't be that bad and everything would be possible to tidy up eventually, right? Well, as a result, after merging and pushing some more temporary commits my local history has become a little bit messy and I don't really know whether this can be cleaned somehow without messing up the upstream history.
Let's say the history looks something like PR=c1->c2->c3->upstream1->upstream2->upstream3->c4->c5. In that example c1..c6 would be my local changes and upstream1..upstream3 would be committing ahead from upstream.
QUESTIONS
- Was my decision of merging a really bad choice when upstream got very far away ahead from my unfinished PR? What would have been the best way to proceed in that case? Consider my goal is ending up with a single squashed commit merged into upstream eventually
- Once the harm is done and I've merged after solving the conflicts and created few more commits, would still be possible to provide a clean PR with just 1 single squashed commit without rewriting upstream history?
I guess the whole thread could be summed up by asking what's the best way to proceed when upstream gets far away from your unfinished PR that contains multiple temporary commits.