How can I modify the login form using hook_form_alter()?
When I go to mysite/user/login it doesn't call the block where I have to alter the form. It simply doesn't call hook_form_alter().


example.com/user/login doesn't show the user login block; it shows the login form. Your code should work, even if I would rather make the code simpler (if you are not using "user-login-form" in any way).

function git_form_alter(&amp;$form, $form_state, $form_id) {
  if ($form_id == 'user_login_block' || $form_id == 'user_login') {
    // …
  }
}


As for the reason why the code doesn't work, I can think of the following reasons:


The hook name doesn't match the short name used for the module; for example, the short name of the module is "git_form" and you are using git_form_alter() for the implementation of hook_form_alter() when it should be git_form_form_alter().
You are editing a module that is enabled. In this case, when you add a new hook to the code, you also need to flush the cache used by Drupal as Drupal caches the list of hooks implemented by third-party modules.
The module is not enabled.