Maybe it’s just me, but I frequently PR my git branch to dev then forget that the git squash removed my old branch and the code I have been working on since the PR needs a new branch. Fortunately, it is easy to create a new branch and move your work to a legitimate branch.
Obviously this is only one of a billion ways to do this. Your mileage may vary.
Process
- Add a commit change message then stash your current changes. The result will be that all of your changes will be safely stored away and your current changes will disappear.
- Create a new branch from the branch the code was checked into for the PR. I do it on the main git repo in Azure DevOps.
- Checkout the new branch locally.
- Restore stash.
This will restore the changes. Be aware that you may need to perform merge operations if the PR branch has changed.