Is it the "end of option" I am used to see in bash (and if yes, why do we use it) or is it a Git notation for the Index or the HEAD?
The git checkout command lets you navigate between the branches created by git branch . Checking out a branch updates the files in the working directory to match the version stored in that branch, and it tells Git to record all new commits on that branch.
Checkout is the command used to switch between the different branches of a GitHub repository. When a branch is checked out, all files in the working directory are updated to match the versions stored in that branch.
The git checkout command can be used in a commit, or file level scope. A file level checkout will change the file's contents to those of the specific commit.
DESCRIPTION Updates files in the working tree to match the version in the index or the specified tree. If no paths are given, git checkout will also update HEAD to set the specified branch as the current branch. checkout (co): Check out a working copy from a repository.
The --
separates the paths from the other options. From the documentation:
git checkout [-f|--ours|--theirs|-m|--conflict=<style>] [<tree-ish>] [--] <paths>...
If this notation didn't exist the following two commands would be ambiguous:
git checkout <tree-ish> <path1> <path2> git checkout <path1> <path2> <path3>
With the --
notation it is clear which is meant:
git checkout <tree-ish> -- <path1> <path2> git checkout -- <path1> <path2> <path3>
The documentation I linked to above includes an example of when you might need it:
$ git checkout hello.c
If you have an unfortunate branch that is named hello.c, this step would be confused as an instruction to switch to that branch. You should instead write:
$ git checkout -- hello.c
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With