git remote set-head origin --auto

Automatically sets the default branch of a remote repository

This command sets the default branch of a remote repository to be the same as the default branch of the local repository.

By using the --auto flag, this command automatically detects the default branch of the local repository and sets it as the default branch of the remote repository.

This is useful when working with multiple branches and ensuring that the default branch remains consistent across both the local and remote repositories.

Other variations of this command include:

  • git remote set-head origin <branch>: Sets the default branch of the remote repository to the specified branch.
  • git remote set-head --delete origin: Removes the default branch of the remote repository, leaving it unset.

Sign in to enable bookmarking, reminders, progress-tracking and more...