mirror of
https://gitlab.com/2009scape/contributor-wiki.git
synced 2026-08-01 14:19:13 -06:00
Add undoing an accidental merge
This commit is contained in:
parent
da3a0d73f2
commit
ae394971ed
1 changed files with 34 additions and 1 deletions
|
|
@ -92,4 +92,37 @@ $ git checkout cider
|
|||
$ git rebase master
|
||||
$ git push origin cider
|
||||
```
|
||||
And now your `cider` branch is updated onto the changes present in the updated master branch.
|
||||
And now your `cider` branch is updated onto the changes present in the updated master branch.
|
||||
|
||||
## Best Practices: Undoing an accidental merge
|
||||
At some point you probably will accidentally merge the main repo into your branch.
|
||||
You will need to undo this; we cannot accept MRs that have a merge as a commit.
|
||||
The sooner you fix it the better.
|
||||
|
||||
Let's say you have accidentally merged changes from the main repo into a branch caller `cider` on your fork.
|
||||
Here's how you can undo it:
|
||||
|
||||
0) If you are worried you may lose some work copy the files somewhere else.
|
||||
In theory you should not lose anything but if you do not feel confident with git copy your changes elsewhere.
|
||||
|
||||
1) Roll your branch back to before you merged (ideally just one commit back):
|
||||
```
|
||||
git reset --hard HEAD~1
|
||||
```
|
||||
|
||||
or
|
||||
|
||||
```
|
||||
git reset --hard {commit hash}
|
||||
```
|
||||
|
||||
2) Force push this rollback to *your* repo/branch (`cider` in this example)
|
||||
|
||||
```
|
||||
git push --force origin cider
|
||||
```
|
||||
|
||||
3) Follow [Best Practices: Updating Your Fork](Git-Basics.md?ref_type=heads#best-practices-updating-your-fork).
|
||||
|
||||
4) If you've lost something you did not backup you can use ```git checkout {hash}``` to try and find the pieces.
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue