Git rebasing on master after squash

Scenario: Your branches are A, B and master. B is dependent on A.

commits:

branchescommits
masterm
Am -> 1 -> 2
Bm -> 1 -> 2 -> 3 -> 4

Commits from A have been squashed and merged into master.

branchescommits
masterm -> 12
Bm -> 1 -> 2 -> 3 -> 4

You want to rebase B on master.

I prefer this:

git rebase --onto master A B

Otherwise: If B has X commits on top of A (In this case X=2)

git rebase --onto master HEAD~[X]

Reference: https://makandracards.com/makandra/45964-git-rebase-dependent-feature-branch-after-squash