What does - - in git checkout mean?

4

When we use git checkout nomedoarquivo what's the difference with git checkout -- nomedoarquivo ?

I do not know what changes in using this -- ?

    
asked by anonymous 31.08.2017 / 16:31

1 answer

4

The command git checkout "nome" (without -- ) will work in the same way as git checkout -- nome (with -- ) when there is no branch with the same name as file .

If there is a branch and file with the same name in the project, then the user has to specify which one to checkout.

  • git checkout -- nome to choose the file
  • git checkout nome to choose the branch

The -- serves to avoid confusion. Indicating that the user is checking out a file rather than a branch with the same name.

Git is smart enough to try to match the command if there are no files and branches with the same names. That's why you saw no difference in the results of the commands.

In fact, it is not just with branchs that ambiguity can occur. As explained in the documentation link in git checkout disambiguation .

    
05.09.2017 / 10:28