Phriction Wiki Sealhub Workflow Audyt i Review Review workflow X3: I've already pushed the changes, how to undo them and create a diff?
Contents
- 1. Create a new branch that points to the latest commit:
- 2. Find the ID of the base commit.
- 3. Move your local main (or master) branch to that commit
- 4. Checkout the newly moved main (or master) branch
- 5. Enable dangerous changes
- 6. Push your local changes to the main branch
- 7. Disable dangerous changes in the repo
- 8. Move back to the my_changes branch and create a diff
X3: I've already pushed the changes, how to undo them and create a diff?
X3: I've already pushed the changes, how to undo them and create a diff?
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 Actions → Manage+Repository
And then click on "Allow dangerous changes"
6. Push your local changes to the main branch
$ git push --force
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
Tags
None
Referenced Files
F630705: image.png | |
Aug 9 2023, 07:33 |
F630710: image.png | |
Aug 9 2023, 07:33 |
Subscribers
None
- Last Author
- migueldar
- Last Edited
- Aug 15 2023, 01:04