Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why do we use double dash in "git checkout -- ."? [duplicate]

Tags:

I thought the line

git checkout . 

can revert all changes in the current directory and subdirectory for the local working copy. But I also see this popular form:

git checkout -- . 

so if -- (the double dash or also called "bare double dash") is to signal the end of command options, then why is it needed in the above case? The . can never be an option so there shouldn't be any confusion.

like image 412
nonopolarity Avatar asked Apr 22 '14 00:04

nonopolarity


People also ask

What does double dash mean in git?

1. 12. For clarity, in git it means more than this, as it also means the argument after the -- cannot be a branch name, and by implication the argument before -- cannot be a file path.

What is dash in git?

The double dash -- in git means different things to different commands, but in general it separates options from parameters. In git specifically, the meaning of -- depends on which subcommand you are using it with.

What are two uses for git checkout?

It can be used to create branches, switch branches, and checkout remote branches.

What is difference between git checkout and clone?

git clone is to fetch your repositories from the remote git server. git checkout is to checkout your desired status of your repository (like branches or particular files). E.g., you are currently on master branch and you want to switch into develop branch.


1 Answers

It's meant to be to resolve ambiguity.

For example, if you had a branch named bob (which would checkout that branch) and a folder named bob (which would revert that folder).

like image 136
alex Avatar answered Sep 27 '22 23:09

alex