Unknown access: Multiple account are locked because of number of failed login attempts

Multiple user accounts are locked because of numbers of failed attempts. Some unknown users or attackers are trying to login to git account. How do they get the user account details??.. How we can block such unknown attempts??