I've been trying to clean up my branch by squashing several commits into one, but things have gone sideways. I pushed my changes and created a pull request to merge into the master branch, which shows four commits. To squash them, I ran `git rebase -i HEAD~10`, marking the last three commits to 'squash' and the one before those to 'rename'. However, after running the command, my local repository seemed to revert back to a state from three years ago, and now I'm facing merge conflicts with commits that aren't even part of the squash process.
When I checked `git log`, I found that HEAD points to a commit from years ago instead of the recent ones I was working on. The "Incoming change" is also from a point way back in time, with many of these commits already merged into master. I attempted to resolve the conflicts by accepting the current changes, but it resulted in a jumbled mess full of syntax errors. What can I do to properly squash these commits without running into these issues?
2 Answers
Have you tried using the website ohshitgit.com? It's a handy resource for troubleshooting Git problems. You might consider aborting the rebase or even deleting your local repo to start fresh if you're stuck. Just be cautious when you try squashing again, or else you might end up in the same situation!
On our team, we usually squash commits to a new branch first before rebasing with master. This makes conflict resolution a lot smoother—definitely worth trying if you haven't!
That's actually smart! I thought squashing directly in the main branch would work fine, but it seems like that just complicates things. I'll give your method a try!

Since you've already pushed those commits, deleting the local repo might not be the best route. Maybe just try resolving conflicts by checking out the `main` branch and then squashing from there? It could save you some headaches.