I understand the scenario presented in Pro Git about The Perils of Rebasing. The author basically tells you how to avoid duplicated commits:
Do not re
You may have pulled from a remote branch different from your current. For example you may have pulled from Master when your branch is develop tracking develop. Git will dutifully pull in duplicate commits if pulled from a non-tracked branch.
If this happens, you can do the following:
git reset --hard HEAD~n
where n ==
Then make sure you are pulling from the correct branch and then run:
git pull upstream --rebase
Pulling with --rebase will ensure you aren't adding extraneous commits which could muddy up the commit history.
Here is a bit of hand holding for git rebase.