To make the AppStore forget the old credentials with which the app was downloaded, you must remove the _MASReceipt directory in the app itself.
To do this:
Open Finder and navigate to Applications,
Ctrl+Click XCode and choose "Show Package Contents",
Expand the Contents directory and click _MASReceipt to select it,
Type Command+Delete to delete the directory permanently---you will be prompted for your credentials since this is a protected file.
Quit and restart AppStore, then find XCode. The button should now say "Free" or "Install" instead of "Update". Clicking it will update your XCode to the latest version as the currently logged-in Apple user.