Yes โ India and Bangladesh did exactly that in 2015
Along their border sat over 150 tiny enclaves, fragments of one country marooned inside the other, a leftover of old princely territories. Residents were cut off from their own government and basic services for decades. In 2015 the two countries simply traded the enclaves, letting around 50,000 people finally choose their citizenship.