What does the "git branch -M" main command do?

Asked

Viewed 667 times

3

I’m creating a new repository and Github gives me the option to use the command:

git branch -M main

What does he do ?

1 answer

4

According to the command documentation git branch, to flag -M assumes the role of --move together with --force.

This means that when executing the command, the branch will be renamed to main, even though this branch already exists (effect caused by --force).

Therefore:

git branch -M main

Is the same as:

git branch --force --move main

If the name of branch before executing the command is, for example, master, after his execution, shall main.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.