Improve checkout HEAD behavior