Not able to understand even with gregs vid solution

Can someone help me with the approach? how does it go to 6? the remainder?

You linked to GregMat’s website, not a question. Did you mean The remainder when 8^12 − 2 is divided by 7