This won't fix branches that already have the code you don't want in them (see below for how to do that), but if they had pulled some-branch
some-branch and now want it to be clean (and not "ahead" of origin/some-branch) then you simply:
git checkout some-branch # Wherewhere 'somesome-branch'branch can be replaced by any other branch
git branch base-branch -D # Wherewhere 'basebase-branch'branch is the one with the squashed commits
git checkout -b base-branch origin/base-branch # Recreatingrecreating branch with correct commits
Note: You can combine these all by putting &&
&& between them.
Note 2Note2: Florian mentioned this in a comment, but who reads comments when looking for answers?
Note 3Note3: If you have contaminated branches, you can create new ones based off the new "dumb branch" and just cherry-pick commits over.
ExampleEx:
git checkout feature-old # Somesome branch with the extra commits
git log # Givesgives commits (write down the id of the ones you want)
git checkout base-branch # Afterafter you have already cleaned your local copy of it as above
git checkout -b feature-new # Makemake a new branch for your feature
git cherry-pick asdfasd # Wherewhere asdfasd is one of the commit ids you want
# Repeatrepeat previous step for each commit id
git branch feature-old -D # Deletedelete the old branch
Now feature-new
feature-new is your branch without the extra (possibly bad) commits!