Moved from NC to VA but worked in VA the entire year

For the first two months of 2024 I lived in NC but worked in VA.  I then moved to VA and continued to work for the same employer.  If I lived in NC the entire year but worked in VA, I believe that I would get a credit on my NC taxes for taxes paid in VA.  How does it work when I move from one state to another?  Do I allocate my earnings based on where I was living at the time?  Does NC get taxes on my VA income for the time that I lived in NC and worked in VA while VA gets taxes on the income that I earned in VA while living in VA?