Consider the following situation:
- you have a package/program/whatever in version control
- you add a feature branch to implement a feature
- as part of the work on this feature, you make some changes/fix bugs to the existing program/package/whatever
- you now want to carry these fixes across to the main branch, but you are not yet ready to merge the feature in
With git, you can achieve something like this a few ways:
- setup a temporary local branch pointing at the feature branch and perform
git rebase --interactive, followed by merging the temporary branch back into master (quick) - use
git cherry-pickto fetch the individual commits you want across (labour intensive)
The trouble with either of these approaches is, once you finally merge the feature branch in, the commits you imported earlier will now appear twice in the history.
You could avoid this if you did a rebase on the feature branch prior to merge. However, you shouldn't push rebased branches out to a shared repository. Having said that, once the feature branch is fully merged, I intend to delete it, so it would be a stale remote anyway (and there would be no need to push the rebase to the shared repository)