During development I often need to commit and push "intermediate" commits, i.e. commits with the code not compilable or in the middle of changing something, etc. I don't want to make such commits, but this is required for easy continuing my work from office to home, sometimes for other developers to get them base on which they can start their work.
I thought I had found a solution for that problem:
I create a separate "dev" branch and make all intermediate commits.
Once the code is in good state, make a merge to master. So the master wouldn't contain "intermediate" commits but only "normal" commits.
Delete the "dev" branch with all intermediate commits.
But this doesn't work. When I make merge, not only the merge commit is included to master, but also all "intermediate" commits from "dev" branch too. So deleting "dev" branch gives nothing, its "intermediate" commits stay there.
So the questions is: is it possible to make merge in the way that master would include only its own commits + merge commit and not include the commits from the second branch? If it's impossible, could you advice me how to achieve my goal - to have the ability to temporary save intermediate results but also seamlessly delete them later?