Deductions & credits

If you moved due to a "hardship" you qualify for a partial exclusion.  For example, if you are married, and lived there 18 months, you can get 18/24th of the $500,000 exclusion, or about $375,000, more than enough to cover you. 

If you did not know that your company or job would probably move when you bought the house, then that qualifies as a hardship.  There will be questions to indicate this on your tax return when you file next spring.