The following order of commands helped me:
- remove .git folder
- copy .git from other repo
- now git checkout
Before Removing, You can try
git fetch --all
git reset --hard origin/master
The result showed me that some file names were too long for git to pull them from my remote repository and hence the mismatch and incorrect builds occurred.
So I ran the following command in order to fix it and did a hard reset again.
git config --system core.longpaths true