Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Are GIT refs always case insensitive?

Tags:

git

I was testing on my local machine (OS-X 10.10) which uses a case insensitive file system (HFS+ [CI]) - when I reset to the head:

$ git reset head --hard
$ git reset HEAD --hard

and

$ git checkout 4f2c
$ git checkout 4F2C

Have the exact same results. To my understanding GIT stores refs inside ./git/refs but does the case sensitivity of the underlying file system affect the results?

Would I get the same results on a case sensitive file system?

like image 957
max Avatar asked Jun 28 '15 17:06

max


People also ask

What are refs in Git?

A ref is an indirect way of referring to a commit. You can think of it as a user-friendly alias for a commit hash. This is Git's internal mechanism of representing branches and tags. Refs are stored as normal text files in the .git/refs directory, where .git is usually called .git .

Are branches case-sensitive Git?

Git branches are not case sensitive. So if you have a branch abc123 locally and you push, it can match up to ABC123 on the remote server.


2 Answers

No, you would not get the same results on a case sensitive filesystem. If you ran:

git reset branch --head

on a case sensitive filesystem then that is not the same as running:

git reset BRANCH --hard

Since references are often stored on the filesystem (in the .git/refs/heads folder), the case sensitivity of the filesystem comes into play. On a case sensitive filesystem, .git/refs/heads/branch and .git/refs/heads/BRANCH are two different files.

Note that even on a case insensitive filesystem, your references may end up "packed", in a file specifying on reference per line. In this case, your references are always case sensitive, regardless of your filesystem.

like image 40
Edward Thomson Avatar answered Oct 12 '22 01:10

Edward Thomson


Yes, they are case insensitive. No, a case sensitive file system will not matter. Because git refs are part of a SHA-1 hash, and those are hexadecimal digits (base-16, they just look like letters). At least for the commit-id. As pointed out by @EdwardThomson in the comments, a ref-name may (or may not) be case-sensitive (that depends on the underlying filesystem and whether or not the storage mechanism is loose or packed).

like image 177
Elliott Frisch Avatar answered Oct 12 '22 02:10

Elliott Frisch