If you accidentally pushed your changes to the repository, you can undo those changes and create a diff for review using following steps. Assume this state of the repository:
```
01ccb2a6 (HEAD -> main, origin/main, origin/HEAD) my unreviewed changes 3 # ← whoops! pushed to origin/main!
8f808730 my unreviewed changes 2
3bc05b39 my unreviewed changes 1
99c9f590 Landed diff D1234
126291f7 Landed diff D1235
4e443496 Landed diff D1231
...
```
# 1. Create a new branch that points to the latest commit:
```
$ git checkout -b my_changes
```
```
01ccb2a6 (HEAD -> my_changes, main, origin/main, origin/HEAD) my unreviewed changes 3 # ← whoops! pushed to origin/main!
8f808730 my unreviewed changes 2
3bc05b39 my unreviewed changes 1
99c9f590 Landed diff D1234
126291f7 Landed diff D1235
4e443496 Landed diff D1231
...
```
# 2. Find the ID of the base commit - that is, the last commit before your changes that you want to submit for review.
```
01ccb2a6 (HEAD -> my_changes, main, origin/main, origin/HEAD) my unreviewed changes 3
8f808730 my unreviewed changes 2
3bc05b39 my unreviewed changes 1
99c9f590 Landed diff D1234 # ← that's the one we're looking for
126291f7 Landed diff D1235
4e443496 Landed diff D1231
...
```
store it in a shell variable:
```
$ PREV_TIP=99c9f590
```
# 3. Move your local `main` (or `master`) branch to that commit
```
$ git branch -f main $PREV_TIP
```
```
01ccb2a6 (HEAD -> my_changes, origin/main, origin/HEAD) my unreviewed changes 3
8f808730 my unreviewed changes 2
3bc05b39 my unreviewed changes 1
99c9f590 (main) Landed diff D1234 # ← main moved here
126291f7 Landed diff D1235
4e443496 Landed diff D1231
...
```
# 4. Checkout the newly moved `main` (or `master`) branch
```
$ git checkout main
```
```
01ccb2a6 (my_changes, origin/main, origin/HEAD) my unreviewed changes 3
8f808730 my unreviewed changes 2
3bc05b39 my unreviewed changes 1
99c9f590 (HEAD->main, HEAD) Landed diff D1234 # ← main moved here
126291f7 Landed diff D1235
4e443496 Landed diff D1231
...
```
# 5. Enable dangerous changes
We're about to push the new branch, overwriting the state on the server. This is forbidden by default, but we can temporarily enable it by using "enable dangerous changes" on that repository.
Go to the repository page and click on {key Actions} → {key Manage Repository}
{F630705 width=500}
And then click on "Allow dangerous changes"
{F630710 width=500}
# 6. Push your local changes to the main branch
```
$ git push
```
```
01ccb2a6 (my_changes, HEAD, origin/HEAD) my unreviewed changes 3
8f808730 my unreviewed changes 2
3bc05b39 my unreviewed changes 1
99c9f590 (HEAD->main, origin/main) Landed diff D1234 # ← main moved here
126291f7 Landed diff D1235
4e443496 Landed diff D1231
...
```
# 7. Disable dangerous changes in the repo
See point 5
WARNING: It's super important to disable dangerous changes asap!
# 8. Move back to the `my_changes` branch and create a diff
```
$ git checkout my_changes`
$ arc diff main