Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is HEAD in git case insensitive on all platforms?

Tags:

git

Using msysgit on Windows, I can do this:

git checkout head

or

git checkout HEAD

Either works. I don't have a linux environment to test on, but I'm just curious: is HEAD case insensitive by design? Is it this way on all platforms?

like image 850
void.pointer Avatar asked Sep 22 '14 14:09

void.pointer


People also ask

Are Git files case-sensitive?

The Windows and macOS file systems are case-insensitive (but case-preserving) by default. Most Linux filesystems are case-sensitive. Git was built originally to be the Linux kernel's version control system, so unsurprisingly, it's case-sensitive.

Is Git case-sensitive for folder names?

Git is a unix based code. its is case sensitive so it will allow you to have the same name in different cases, and as you except windows will not be tolerated for this. There is nothing you can do about it beside renaming your folders.


4 Answers

HEAD is case-sensitive on Linux.

For example:

$ git checkout head
error: pathspec 'head' did not match any file(s) known to git.
$ git checkout HEAD
Your branch is up-to-date with 'origin/master'.

Git version 1.9.1 on Ubuntu 14.04.

like image 67
Chris Avatar answered Oct 02 '22 20:10

Chris


The case-sensitivity of HEAD is depending on the case-sensitivity of file system of the OS.

When you checkout HEAD, git actually looks for a file named "HEAD" under the folder .git. If you type HEAD in small letters, git looks for the file name with small letters. You can see the .git/HEAD file actually contains the hash code of the commit HEAD pointing to.

Because of this, the typical case-sensitivities of HEAD are:

  • Case-sensitive on Linux
  • Case-insensitive on Windows, MacOS
like image 42
palazzo train Avatar answered Oct 02 '22 19:10

palazzo train


Answering to cover Mac OSX (Mavericks):

$ git checkout HEAD
Your branch is up-to-date with 'origin/master'.

but:

$ git checkout head
Note: checking out 'head'.

You are in 'detached HEAD' state. You can look around, make experimental
changes and commit them, and you can discard any commits you make in this
state without impacting any branches by performing another checkout.

If you want to create a new branch to retain commits you create, you may
do so (now or later) by using -b with the checkout command again. Example:

  git checkout -b new_branch_name

HEAD is now at f44b740... fix if endScreen(s) not present

By the way, that hash is the head of the current branch (in my test, the same has contained in .git/refs/heads/master)

Interesting behaviour.

(git 1.8.5.2)

like image 44
Lorenzo Marcon Avatar answered Oct 02 '22 19:10

Lorenzo Marcon


HEAD is case sensitive in Linux environment. As far as I know its case insensitive only in mysysgit.

In Linux environment it gives : error: pathspec 'head' did not match any file(s) known to git.

like image 43
Mudassir Razvi Avatar answered Oct 02 '22 19:10

Mudassir Razvi