I want to know how to squash some commits that are upstream of a merge. Below is an attempt at doing this, which resulted in the newly squashed branch becoming independent, while leaving the original commits un-merged.
$ git checkout dev-track_rpm
Switched to branch 'dev-track_rpm'
$ git lg
**removed a bunch of log for brevity**
| * 6802588 - (2 months ago)
* | 267b937 - (1 month ago)
|/
* 45f7846 - (2 months ago) Merge branch 'dev-track_rpm'
|\
| * 7e07b43 - (2 months ago) (HEAD, dev-track_rpm)
| * 5cce85b - (2 months ago)
| * e36f2fb - (2 months ago)
| * 081175b - (2 months ago)
* | 4896e1f - (2 months ago)
|/
* 4767c9d - (2 months ago)
$ git rebase -i -p 4767c9d **also tried without -p initially**
*choose to squash 5cce85b and e36f2fb**
[detached HEAD c77cf3e]
20 files changed, 4139 insertions(+), 0 deletions(-)
**removed file list for brevity**
Successfully rebased and updated refs/heads/dev-track_rpm.
$ git lg
* 260cdce - (2 months ago) (HEAD, dev-track_rpm)
* c77cf3e - (2 months ago)
**removed same bunch of log for brevity**
| | * 6802588 - (2 months ago)
| * | 267b937 - (1 month ago)
| |/
| * 45f7846 - (2 months ago) Merge branch 'dev-track_rpm'
| |\
| | * 7e07b43 - (2 months ago)
| | * 5cce85b - (2 months ago)
| | * e36f2fb - (2 months ago)
| | * 081175b - (2 months ago)
| |/
|/|
| * 4896e1f - (2 months ago)
|/
* 4767c9d - (2 months ago)
$
I wanted to get this:
$ git lg
**removed a bunch of log for brevity**
| * 6802588 - (2 months ago)
* | 267b937 - (1 month ago)
|/
* 45f7846 - (2 months ago) Merge branch 'dev-track_rpm'
|\
| * <some new sha> - (2 months ago) same changes as 7e07b43 (HEAD, dev-track_rpm)
| * <some new sha> - (2 months ago) squashed
* | 4896e1f - (2 months ago)
|/
* 4767c9d - (2 months ago)