0

The following image is a directory structure of a project of Android Studio, the app can be committed to GitHub correctly.

Now I add a folder named MyNewFolder to the structure. I hope to commit the MyNewFolder to GitHub, so I right-click the folder MyNewFolder and select the menu item Git -> Commit Directory... , but system displays "No changes detedcted", why?

Image 1

enter image description here

Image 2

enter image description here

HelloCW
  • 476
  • 10
  • 77
  • 178

1 Answers1

1

TLDR: to commit a new, empty-ish folder, you'll have to put a file in it. (.keep, .gitignore, or README are common choices)

Git "detects no changes" because git uses its index file to generate commits, and index only tracks files. Directories exist in the index only as parts of file paths.

Here's some discussion of why this is the case, and a link to the git FAQ on the subject. On the off chance you actually need to commit an 'empty' folder, here are some hacks that will make it work.

Chris Keefe
  • 475
  • 5
  • 13