Committed while in Master Branch?
We've worked all day to get a push done by day's end. Multiple commits and other pull requests/builds going on throughout the day. We didn't merge master with local branch before pushing.
We see the pull request and attach a task to begin the dev build from VSTS. It immediately fails with merge conflicts.
The Good News
Because we were on a branch and committed prior to the push; we are able to know our changes won't be lost.
How to fix
- Ensure there are no more changes in local branch. Either stash or push until no changes remain.
- Switch over to master branch and do a "git pull"
- Switch back to the "other" local branch.
- Type in "git merge master"
- We should see files show up in Visual Studio Code as changes with a "C" status indicating conflict.
- Browse through each file one at a time and note that the "Current" changes are the changes that were pushed prior but failed. The 'incoming' are from the master branch.
The current changes are most likely the ones desired. Ensure this is true by examining all "Current" changes compared to the "Incoming" changes. If the "Current" changes are the ones needed, close the file then right click on that file name in the "Changes" view and select "Accept all Current".
- The file changes will then open in edit MODE. Inspect and close file when all is good.
- No right click again on this file and select "STAGE Changes"
- Repeat for each file showing a "C" (Conflict)
- When done, push all the changes and the pull request should restart automatically!
A Better Way
Just do the master merge bit before the first push.
To complete the merge just stage all the changes.
JWP2020 Merge Conflicts