Phriction Wiki Sealhub Workflow Audyt i Review Review workflow X3: I've already pushed the changes, how to undo them and create a diff? History Version 1 vs 2
Version 1 vs 2
Version 1 vs 2
Edits
Edits
- Edit by kuba-orlik, Version 2
- Aug 9 2023 07:36
- Edit by kuba-orlik, Version 1
- Aug 9 2023 07:33
Original Change | Next Change » |
Edit Older Version 1... | Edit Older Version 2... |
Content Changes
Content Changes
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 (HEAD, origin/main, origin/HEAD) my unreviewed changes 3
8f808730 my unreviewed changes 2
3bc05b39 my unreviewed changes 1
99c9f590 (HEAD->main) Landed diff D1234 # ← main moved here
126291f7 Landed diff D1235
4e443496 Landed diff D1231
...
```
5. 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}
6. Push your local changes to the main branch
`git push`
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. 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. Move back to the `my_changes` branch and create a diff
```
$ git checkout my_changes`
$ arc diff main
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 (HEADmy_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. 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```
$ 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. Move back to the `my_changes` branch and create a diff
```
$ git checkout my_changes`
$ arc diff main