I need to checkout and pull our prod branch. I checked it out some time ago, and havent changed anything.
However people have force-pushed changes to prod branch, causing thousands of conflicts with my local copy when I try to pull.
If I try to delete the prod branch, I get:
% git branch -d prod
error: Cannot delete branch 'prod'
If I try to switch away from the prod branch, I can't:
% git checkout main
ui.front/src/components/Navigation/Navigation.tsx: needs merge
error: you need to resolve your current index first
Any suggestions?
Is there some sort of force checkout or force pull? checkout -f doesnt help.
May be something like this would work, but I'm too scared to it unless someone can confirm it won't break anything and its the right thing to do:
git fetch --all
git reset --hard origin/prod
CodePudding user response:
- Cleanup your current prod branch by either stashing, recommended (
git stash) or if you don't care about the changes (git reset --hard) git branch -m prod_backup# to rename your current prod banch to prod_backup (just in case)git fetchgit checkout prodyou should now have the changes which your colleagues pushed
CodePudding user response:
I could not find a way to delete the offending branch, but I can confirm that the following worked:
git reset --hard origin/prod
git pull
