Resetting your fork with the original on github

Many a times our students face the need to reset their fork completely to make it equal to the original repository. On github, they fork the original project and make some changes, commits and even pushes and then all of sudden realize that they are not happy with the end results and they want to start over fresh, completely discarding their work in their fork and resetting it with the latest content from the original repo. Below piece of commands (found here) (executed from your terminal / command prompt) lets you achieve it.

Beware that these commands will make your complete work go away from your fork and reset the content back to that of the original.

$ cd <your local repo>
git remote add upstream /url/to/original/repo.git
git fetch upstream
git checkout master
git reset --hard upstream/master  
git push origin master --force 

Comments