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
.
What is the correct name for a parameter that accepts any of
bar
,origin/bar
,deadbeef
, or the literal stringHEAD
?What is the correct name for a parameter that accepts
foo:bar
orfsckur:bar
? Please clarify if this is github functionality rather than git.If not yet clear from 1 and 2, what is the difference in git terminology between
commitish
,ref
andrefspec
?
CodePudding user response:
Definitions from the glossary
commit-ish
ref
refspec
Answering your sub-questions
- A parameter that accepts any of bar,
origin/bar
,deadbeef
, or the literal stringHEAD
...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>
.
- the correct name for a parameter that accepts
foo:bar
orfsckur:bar
...is a <refspec>
, as described in git push man page for example, but you have it also for fetch
or pull
.
- 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.