I’ve been working on a project and I recently made some pull requests for some updates I did in 5 new branches I created. The owner of the repo decided to release a new version of the website without merging my code first, so the pull requests no longer exists on the repo. He wants me to pull the new version to my local machine and make the pull requests on this new version.
If I pull the new code to the main
branch on my local machine, then switch to one of the other branches I created to remake a pull request, I’ll just be sending the old code he updated elsewhere on the website along with the changes I made. Also seeing that I’ve already made all the commits and pull requests if I try to commit the files again I may get a message telling me there’s no new changes to commit as I’ve run into in the past.
I’ve never encountered this type of situation before so I’m not sure about what I need to do. Do I pull to the main branch then merge it with my other branches first? If so how do I prevent the merge from over writing my changes? Will git stash
even know what to stash in this scenario seeing that there’s no commits and everything is up to date as far as my local machine is concerned? Will git fetch
be a better course of action to manually prevent it from overwriting the code I don’t want it to overwrite? What should I do?
3
Workflow for such cases is
git checkout -b new_branch_name
# make changes
git add .
git commit -m "save changes to commit"
git push
create pull request at Github
repo’s owner releases new version without merging PR
Then there are 2 cases:
1 case) PR still exists in repo, can be merged in Github (if there are no conflicts, if yes – just make changes)
2 case) you locally can do
git checkout master
git pull
git checkout new_branch_name # from the beginning
git merge master
git push
And your PR will be updated