Azianese
Azianese

Reputation: 624

How to remove a duplicate directory with a case-sensitive name?

I had duplicate directories in Github (differing in case). It seems they are both tracked to a single directory in my local. How do I properly delete one of the directories without affecting my local?

General steps I took (IIRC):

  1. I had a directory, let's say "MyDirectory".
  2. I pushed some code in that directory to Github.
  3. I changed the directory name to "mydirectory".
  4. I realized that github is not case-sensitive by default (all my code changes were added to to "MyDirectory" in Github), so I ran "git config core.ignorecase false".
  5. I re-pushed the changes, which created a new directory in Github. (At this point, Github has 2 directories, one named MyDirectory and the other named mydirectory. My local only has mydirectory.)
  6. I couldn't figure out a good way to delete MyDirectory from Github, so I manually deleted all the files inside it following these steps.
  7. Now, when I run git pull, it deletes mydirectory from local (I don't want that.)

Upvotes: 4

Views: 2852

Answers (1)

Code-Apprentice
Code-Apprentice

Reputation: 83527

TLDR: Don't set core.ignorecase=false. This is opposite of what your operating system actually does and causes git to behave unexpectedly.

I think there is some confusion here about file names, Git, and GitHub.

  1. The file system from your operating system: Linux and Mac use case-sensitive file names. Windows file names are case-insensitive.

  2. Git: Git has a configuration called core.ignorecase that you can set. This is used to inform Git about the behavior of your operating system. If you set it opposite of what your operating system actually does, then Git will behave in unexpected ways. Note that this doesn't modify the case sensitivity of the underlying file system.

  3. Git Hub: This is a web service that is built on top of Git. For this discussion, it is not really a factor as case sensitivity of file names is not managed at this level.

Additionally, Git does only tracks file contents. It does not track directories directly. The only way to remove a directory from Git's version control is to remove the files from that directory.

I know this doesn't directly answer your question, but I hope it clarifies how these three pieces contribute to the issue.

Upvotes: 3

Related Questions