Home > Blockchain >  Correct terminology for types of git ref
Correct terminology for types of git ref

Time:08-09

The git docs mention commitish, ref and refspec.

I write scripts. I want my terminology to be correct, so other people learn git as they use the scripts.

In my repo foo, I have a remote origin that points to my upstream https://github/fsackur/foo. My branch bar is checked out at SHA deadbeef and tracks origin/bar.

  1. What is the correct name for a parameter that accepts any of bar, origin/bar, deadbeef, or the literal string HEAD?

  2. What is the correct name for a parameter that accepts foo:bar or fsckur:bar? Please clarify if this is github functionality rather than git.

  3. If not yet clear from 1 and 2, what is the difference in git terminology between commitish, ref and refspec?

CodePudding user response:

Definitions from the glossary
commit-ish
ref
refspec


Answering your sub-questions

  1. A parameter that accepts any of bar, origin/bar, deadbeef, or the literal string HEAD

...as eftshift0 already mentioned in his comment on the question, would be a <commitish>, meaning anything that can be ultimately dereferenced down to a commit hash. So it could as well be a branch, a commit hash, a tag, many things. As Joachim Sauer commented below, most of the time simple refs are used for <commitish>.

  1. the correct name for a parameter that accepts foo:bar or fsckur:bar

...is a <refspec>, as described in git push man page for example, but you have it also for fetch or pull.

  1. what is the difference in git terminology between commitish, ref and refspec?

The third one from your list we didn't mention yet is the simple ref, which basically means "variable" in git. The .git/refs folder of a git repo is storing variables along with their value, which is a hash.

  •  Tags:  
  • git
  • Related