"How did you know I was here" is correct.
New words, one handy idiom, and a 2-minute quiz — delivered to your inbox to keep your streak alive.
plumtt12"how did you know I was here?"Before he found you, he knew where to go. (All this happened in the past.) It doesn't matter where you are at the moment of speaking. You are talking about the past.