Follow the technical advice in the technically-oriented answers; it's good stuff. My answer is more about attitude.
Feeling bad about making the kind of mistake every developer makes occasionally is just absurd, and doesn't help you not make that kind of mistake in the future. While you sit there feeling bad, the build is still broken, you know? And then your work is all about avoiding mistakes, which I know makes getting out of bed in the morning an exciting adventure every day, right?
I've heard of companies where checking in broken code is cause for public shaming. I can't even get my head around the kind of warped, frat-boy, junior-high-level thinking that would lead to such behavior. There could hardly be ANYTHING more counter-productive for a team lead or manager to do.
So don't beat yourself up. We've all done it. I probably cost myself half a day per week in silly mistakes, and I've been doing this for (cough) a long time. That's what it looks like to write code--you're constantly bashing up against what seems like your own inadequacies. What makes a professional a professional isn't some mythical quality of never ever making mistakes (including big ones sometimes), but how they RESPOND to the mistakes they make.
If there's one mantra I could instill in every developer I work with, it's this: You are not your code. You write code. You write it as well and efficiently as you can. Then you go home. If you equate your value or self-worth as a person with the quality of your code, you're just missing the boat about who you really are.