By recursively changing your directories and files to mode 0777
, you're turning on the executable bit for all your files, which git will dutifully attempt to record.
You can't easily get git to ignore these permission changes -- at least, not without giving up git's ability to understand your filesystem's executable permission bit altogether.
Setting directories and files world writable is a bit of a code smell, if I'm honest, and I'd try to find a more granular, less heavy handed approach to this. But putting that aside, there are two approaches.
First, you can let umask
do the heavy lifting for you -- this is likely the easiest solution. Your umask
informs how new files will be created. Run umask -S
to see the current settings (in human readable form). Mine is 022
or u=rwx,g=rx,o=rx
, which means that new files will be created in mode 0755
or 0644
if they're not executable.
Setting your umask
to 0
will mean that directories will be created with mode 0777
, regular files as 0666
and executable files as 0777
.
(umask 0 && git clone git@github.com:ethomson/test)
We wrap this within parentheses ((...)
) because that will start a subshell. Your umask 0
will persist only as long as the subshell, meaning it will only affect the git clone
command, not things you run in the shell after that.
If you look inside the cloned test
repo, folders will be mode 0777
, regular files will be 0666
, and executable files will be 0777
.
Using umask
is probably the simplest option overall but you will need your umask
to be 0
for all git operations that write files.
If that's too burdensome, you can, however, use a modification of your chmod
after the fact.
chmod -R 0777 <directory>
will set the given directory and all subdirectories to world readable, writable, and seekable. It will set all files within that directory, and subdirectories, to world readable, writeable, and executable.
You probably want the former -- you want directories to be mode 0777
, but you probably don't need the latter -- I don't know your precise workflow, but you probably only need them to be 0666
(meaning world writable). If at all -- again, this feels like a lot.
Instead you can make all directories 0777
-- find
with the -type d
option will find all directories.
find /storage -type d -exec chmod 0777 {} \;
while making all files world writable -- first, setting executable files to 0777
, then setting non-executable files to 0666
:
find /storage -type f -perm -100 -exec chmod 0777 {} \;
find /storage -type f \! -perm -100 -exec chmod 0666 {} \;
The first command will find all files (-type f
) that have the user write bit set (-perm -100
) and then will chmod them; the second command will find all files that do not have the user write bit set (\! -perm -100
) and chmod them.