Resolve Git local changes to the following files would be overwritten
·Feb 10, 2023·
1 min read
I ran into a new conflict using git today that took a bit of wrangling 🤠
"𝗬𝗼𝘂𝗿 𝗹𝗼𝗰𝗮𝗹 𝗰𝗵𝗮𝗻𝗴𝗲𝘀 𝘁𝗼 𝘁𝗵𝗲 𝗳𝗼𝗹𝗹𝗼𝘄𝗶𝗻𝗴 𝗳𝗶𝗹𝗲𝘀 𝘄𝗼𝘂𝗹𝗱 𝗯𝗲 𝗼𝘃𝗲𝗿𝘄𝗿𝗶𝘁𝘁𝗲𝗻 𝗯𝘆 𝗺𝗲𝗿𝗴𝗲"
I didn't have any changes to commit locally, particularly not on the specified file, nor was anything stashed in my local branch. Despite this, Git continued to prevent me from pulling my latest commits to my master branch so that I could perform a rebase.
I tried the following to rectify this:
git pull git pull --force git pull origin --force git stash pop git stash git stash drop git merge --ff-only origin/master git pull origin master git reset HEAD
But none of these ⬆️ worked.
The solution for me was to:
git checkout path/to/file/to/revert git reset HEAD path/to/file/to/revert git pull
I was then able to switch back to my local branch, rebase the master branch, fix some conflicts and move on with my day 😎
Have you run into this particular scenario before? Any other suggested commands that worked for you?