I tried to create folder in my local git repo using mkdir. It didn't work, but
mkdir -p
works.
Why?
I'm using Mac OS by the way. I checked the definition of mkdir -p. But I still don't quite understand.
I tried to create folder in my local git repo using mkdir. It didn't work, but
mkdir -p
works.
Why?
I'm using Mac OS by the way. I checked the definition of mkdir -p. But I still don't quite understand.
From the help of mkdir: -p, --parents no error if existing, make parent directories as needed
So you failed maybe just because you wanted to create both parent and child folder in one shoot without -p option.
That flag will create parent directories when necessary. You were probably trying to create something with subdirectories and failing due to missing the -p flag
Say you're in the directory:
And you want to make 3 new sub directories to end up with:
While staying in "/home/Users/john", this will fail:
You would have to make three separate calls:
The reason is that mkdir by default only creates directories one level down. By adding the "-p" flag, mkdir will make the entire set in one pass. That is, while this won't work:
this will work:
and create all three directories.