[SOLVED]Preserve file permissions on "git clone"

Using the Gitlab CI I want to preserve file permissions on the project when I clone it and it looks like the docker image made a umask that changes everything to 777:

I’m trying to do a “dpkg-deb” of the directory in order to generate a “deb” file buf I get the following error:

dpkg-deb: error: control directory has bad permissions 777 (must be >=0755 and <=0775)

ERROR: Build failed with: exit code 1

I answer myself, it looks like git ONLY tracks the executable bit on files, permission bits are not tracked.

I have a very similar error message when I try to put in cache all the untracked files. When using the cache again it gives me this strange error. The permissions of the control file are actually good but its parent directory perms are 777.

What do you think is the best way to solve this issue?

-rw-r--r-- 1 root root 454 May  3 16:22 target/deb/DEBIAN/control
drwxrwxrwx 2 root root 4096 May  3 17:12 target/deb/DEBIAN

My current solution is to fix the perms of the directory myself.