Reset and sync local respository with remote branch
If you have ever gotten to the point where your local git repository is out of sync with your remote, but you just can’t seem to restore things back to normal, then this command is for you.
This git pro-tip will turn your local repository into a mirror image of the remote of your choice. Simply follow these steps to get back to frustration-free development.
Remember to replace
master with the remote and branch that you want to synchronize with.
git fetch origin && git reset --hard origin/master && git clean -f -d
git fetch origin git reset --hard origin/master git clean -f -d
Here is an example of running the command on a local clone of the JBoss Forge git repository.
sharkbook:forge lbaxter$ git fetch origin && git reset --hard origin/master && git clean -f -d HEAD is now at 356cd85 FORGE-680 Removing forge-example-plugin/ Removing plugin-container-api/ Removing plugin-container/ Removing shell/.forge_settings sharkbook:forge lbaxter$