From b1ea4b986172125686954186804e4e282ce87c88 Mon Sep 17 00:00:00 2001 From: GregF Date: Mon, 25 Mar 2024 17:35:02 +0000 Subject: [PATCH] Add guide for fixing broken master/main --- Git-Basics.md | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/Git-Basics.md b/Git-Basics.md index cb4d53c..c51e003 100644 --- a/Git-Basics.md +++ b/Git-Basics.md @@ -126,3 +126,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 +```