diff --git a/Git-Basics.md b/Git-Basics.md index b0277b0..8ec1fbc 100644 --- a/Git-Basics.md +++ b/Git-Basics.md @@ -125,3 +125,18 @@ git push --force origin cider 4) If you've lost something you did not backup you can use ```git checkout {hash}``` to try and find the pieces. +## Undoing updating a local master +It's possible at some point you accidently update your master branch. This will cause you problems. Before you do this you will need to temporarly allow [force pushing](https://docs.gitlab.com/ee/user/project/protected_branches.html#allow-force-push-on-a-protected-branch) to your master branch. Make sure to turn it off afterwards. + +1) Get the latest upstream files +``` +git fetch -ap upstream +``` +2) Reset your master branch. **Warning you will lose any locally changed files that are only on master!** +``` +git reset --hard upstream/master +``` +3) Push to your master branch +``` +git push origin master --force +```