Merge branch 'git-help' into 'main'

Add guide for fixing broken master/main

See merge request 2009scape/contributor-wiki!2
This commit is contained in:
Ceikry 2024-08-30 17:43:27 +00:00
commit 7df998bf0b

View file

@ -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
```