What is the reason that in git we can refer to HEAD by --?

noisy

We all know git status command, and beginning of its output:

$ git status
On branch add_multiple_items_to_set__to_master
Changes not staged for commit:
  (use "git add/rm <file>..." to update what will be committed)
  (use "git checkout -- <file>..." to discard changes in working directory)

the last mentioned line suggest that we should use -- to refer to last commit - HEAD.

I always wondered from where this come from. It took me a while to figured out, that I can use git checkout HEAD <file>... and expect this same result, and that git log -1 -- and git log -1 HEAD also is this same.

In which statements -- syntax are more natural? Are there any other multiple dashes shortcuts, like ---, etc.?

Chris

-- is not specific to Git, and it doesn't refer to HEAD.

It is a commonly used argument in Unixy command-line tools indicating the end of the options. Basically, it says "anything following me is a regular argument, not an option, even if it starts with - or --".

It's a way to let the tool operate on, say, a file called --foo:

git checkout --foo
# Um... I don't have an option called --foo. Time to bail out!

git checkout -- --foo
# Ooh, look! I'll operate on this perfectly valid file called --foo

Git just happens to default to using HEAD for many commands.

See also

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

Can we tell the reason for failure of git command in zshrc function?

From Java

What is HEAD in Git?

From Dev

in git what is <<<< HEAD stand for?

From Java

What's the difference between HEAD^ and HEAD~ in Git?

From Dev

What is the reason of error on git push?

From Dev

What is Git HEAD@{x}

From Dev

What is the opposite of 'git checkout HEAD^'?

From Dev

Is there a reason we can't populate types with DataKinds?

From Dev

Why does git HEAD~[N] only refer to pull requests?

From Dev

Try to merge git branch and get <<<<<<< HEAD in some files. What does it mean and how can I repair this?

From Java

What does git push origin HEAD mean?

From Dev

Can we combine git tags?

From Dev

What does a "git repository" refer to precisely?

From Dev

Can't find `HEAD` in git rebase conflict?

From Dev

What can be the reason to use "controllerAs" property?

From Dev

Can we refer to two different tables for one foreign key?

From Dev

Can not push to git: git considers me to be other user for some reason

From Dev

what are different ways between we git diff?

From Dev

what are different ways between we git diff?

From Dev

Git: HEAD vs head

From Java

Git - Can we recover deleted commits?

From Java

What's the difference between HEAD, working tree and index, in Git?

From Dev

In Git, What is the difference between "remotes/origin/HEAD" and "remotes/origin/master"

From Dev

Git Push: What is the difference between HEAD:refs/heads/<branch> and <branch>?

From Dev

What should "git rev-list origin..HEAD" return?

From Dev

git: What does an extra item "origin/HEAD" mean

From Dev

Git Push: What is the difference between HEAD:refs/heads/<branch> and <branch>?

From Dev

Meteor - what can and can't be included in the HEAD tag in 2016

From Dev

What conditions can we put as part of an ON of a JOIN?

Related Related

  1. 1

    Can we tell the reason for failure of git command in zshrc function?

  2. 2

    What is HEAD in Git?

  3. 3

    in git what is <<<< HEAD stand for?

  4. 4

    What's the difference between HEAD^ and HEAD~ in Git?

  5. 5

    What is the reason of error on git push?

  6. 6

    What is Git HEAD@{x}

  7. 7

    What is the opposite of 'git checkout HEAD^'?

  8. 8

    Is there a reason we can't populate types with DataKinds?

  9. 9

    Why does git HEAD~[N] only refer to pull requests?

  10. 10

    Try to merge git branch and get <<<<<<< HEAD in some files. What does it mean and how can I repair this?

  11. 11

    What does git push origin HEAD mean?

  12. 12

    Can we combine git tags?

  13. 13

    What does a "git repository" refer to precisely?

  14. 14

    Can't find `HEAD` in git rebase conflict?

  15. 15

    What can be the reason to use "controllerAs" property?

  16. 16

    Can we refer to two different tables for one foreign key?

  17. 17

    Can not push to git: git considers me to be other user for some reason

  18. 18

    what are different ways between we git diff?

  19. 19

    what are different ways between we git diff?

  20. 20

    Git: HEAD vs head

  21. 21

    Git - Can we recover deleted commits?

  22. 22

    What's the difference between HEAD, working tree and index, in Git?

  23. 23

    In Git, What is the difference between "remotes/origin/HEAD" and "remotes/origin/master"

  24. 24

    Git Push: What is the difference between HEAD:refs/heads/<branch> and <branch>?

  25. 25

    What should "git rev-list origin..HEAD" return?

  26. 26

    git: What does an extra item "origin/HEAD" mean

  27. 27

    Git Push: What is the difference between HEAD:refs/heads/<branch> and <branch>?

  28. 28

    Meteor - what can and can't be included in the HEAD tag in 2016

  29. 29

    What conditions can we put as part of an ON of a JOIN?

HotTag

Archive