In our remote github repository I opened a pull request and merged a old branch (let's call it "legacy") into a current development branch (let's call it "dev") whilst restructuring some code from previous committers that was abandoned.
I already had a local copy of the dev branch on my machine, after the merge I realised I hadn't updated the remote repository with my latest changes and went to commit and push them. This of course failed, so I pulled the remote changes into the local branch, this went through as a merge without any conflicts but I am unsure if my local changes have been preserved (I haven't pushed to the remote since this just in case and the changes were too long ago to remember and check myself).
I can undo the merge remotely, how would I go about undoing the pull request locally so that I can revert to my local commits, then push to remote dev branch and re-merge the branches remotely?
For context, my local result of git log
with dev staged is:
commit _ (HEAD -> dev)
Merge: _
Author: _
Date: _
Merge branch 'dev' of github.com:repository into dev
dev <- legacy merged remotely, local changes to dev branch were not updated prior to this merge, now merging local to update remote repository with this latest commit
commit _
Author: _
Date: _
Local changes to dev
commit _ (origin/dev)
Merge: _
Author: _
Date: _
Merge pull request #N from repository
Previous unrelated commits...
Thank you for any help.
EDIT: @TTT requested a log graph to help explain
* commit 26d51b05874292a8bfe2e28d3bf4ae43d149876b
|\ Merge: 3d28f9a 3d5edeb
| | Author: user_me
| | Date: _
| |
| | Merge branch 'dev' of github.com:origin into dev
| | dev <- legacy merged remotely, local changes to dev branch were not updated prior to this merge, now merging local to update remote repository with this latest commit
| |
| * commit 3d5edeb25245d5cb8893a6717e97c7482b11f479
| |\ Merge: d68769c f9c471e
| | | Author: user_me
| | | Date: _
| | |
| | | Merge pull request #21 from origin/legacy
| | |
This is the current log graph. Showing the merge and then a pull into local in a quick attempt to fix. There were no merge conflicts apparently so I either need a way to fix this or a way to check that the local commits were preserved correctly.
The aim is to have it look more like this, such that local commits were pushed first and THEN legacy was pulled into dev. I just did it out of order and want to fix it.
* commit _
|\ Merge: _
| | Author: user_me
| | Date: _
| |
| | Merge branch 'dev' of github.com:origin into dev (updating local/dev branch after remote merge into origin/dev)
| |
| * commit 3d5edeb25245d5cb8893a6717e97c7482b11f479
| |\ Merge: d68769c f9c471e
| | | Author: user_me
| | | Date: _
| | |
| | | Merge pull request #21 from origin/legacy
| | |
| * | commit _
|/| | Merge: _
| | | Author: user_me
| | | Date: _
| | |
| | | Push local/dev changes into origin/dev
| | |
Remotely I have reverted the merge and reinstated the legacy branch fine (although the local branch is still messed up because of the pull request after the merge), however, despite the branches being different if I go to make another pull request (so I can re-merge after the commits are fixed) it says there is nothing to do as dev is up to date with all commits from legacy, yet they are different?
Based on the updates and the comments, to summarize the problem statement:
After merging a PR into
dev
you realized you hadn't pushed the latest version of your branch which had additional commits. You're wondering how to undo the PR and redo it with the latest version of your branch.
You actually don't need to do "undo" the PR, because you can simply push out the latest version of your branch, and merge those additional commits with another PR. The resulting state will be the same as if you had done it in a single PR the first time. Note that the resulting graph will be slightly different, but that's OK.