Reputation: 9355
I have a local branch, my_branch
, that I made after cloning repo
. I made two commits (more recent commit first):
I pushed my branch and made a PR. It took a while to get it approved and now I can't merge cleanly into origin/master
.
I'd like to get rid of my YAML updates
commit, re-run the process that generates those changes locally, and replay my changes on origin/master
, fixing any conflicts along the way.
Is this the right approach:
Drop my YAML updates
commit with git reset --soft HEAD^
git checkout master; git pull origin master
git checkout my_branch; git checkout origin/master config1.yaml; git checkout origin/master config2.yaml
Re-run process to create YAML updates
git add config1.yaml config2.yaml
git commit -m "Updating YAML files"
git rebase -i master
If I run into merge conflicts, I should fix them and run git rebase --
continue
Assuming 7. is successful, git push -f
EDIT: Is running the same steps above but swapping steps 4. and 7. equivalent to running steps 1. through 8. in sequence?
I'd normally just try the above before asking, but don't want to mess up my local branch or PR.
Upvotes: 2
Views: 59
Reputation: 1327034
The steps do look good, but anyway, you have low risk of messing up:
Is swapping steps 4. and 7. equivalent to running steps 1. through 8. in sequence?
Yes: the rebase change the history of commits anyway: so doing your new commit before or after the rebase won't have any adverse effect, and the last step (8) will remain a git push --force
.
Upvotes: 2