1

This follows on from a previous question of mine but is different insofar as it specifically concerns Git.

When I clone my Git repo on my serer, it dumps the repo successfully but with CHMOD 0755 and, crucially, an owner/group stat of "0/0".

(In my previous question I had assumed this was the server's doing. When I made a folder manually, i.e. mkdir ..., I got the same result, but the answer came that this was because I was doing it as the root user. Changing to the user who owns the CPanel account in question solved the problem.)

However, the problem continues for Git, even though I am running the clone operation as the CPanel user, not root. So:

sudo -u dev -i
echo $USER //<-- "dev"
git clone https://github.com/etc...

What's weird is that I don't get this problem if I make a folder via FileZilla, even though FZ is connected as the same user, i.e. dev.

Any help appreciated.

0

Try:

git config core.filemode false

And then again clone repo.

https://git-scm.com/docs/git-config#Documentation/git-config.txt-corefileMode https://medium.com/@tahteche/how-git-treats-changes-in-file-permissions-f71874ca239d

  • +1 (though I'm too new for my vote to be shown publicly). This was part of the problem but not all of it. In the end it turned out my server had certain defaults as to what owner/CHMOD to give to newly-created files, and somehow GIT was clashing with that. Still not sure exactly what the issue was. – Utkanos Aug 11 at 17:53
0

You may encounter some syntax problem. You could try this:

sudo -i <<-"eoSudoCmd"
    echo $USER
    cd /TargetDir
    git clone https://github.com/etc...
eoSudoCmd

This will suffice if your goal is to obtain root as owner (0 0), But from there, (I don't understand why -u dev in your request), you could simply add -u dev to sudo command, or even:

sudo -i <<-"eoSudoCmd"
    su - dev <<-"eoDevCmd"
         echo $USER
         cd /TargetDir
         git clone https://github.com/etc...
eoDevCmd
eoSudoCmd

(nota for readability, eoDevCmd could by indented, but by Tab only! No spaces!)

  • Thanks for your answer. Alas, a lot of what you say is beyond my comprehension... – Utkanos Aug 21 at 11:42
0

I tried your exact sequence of commands on a Linux server (starting as root user, sudo -i -u dev, and git clone) and the folder was created, as expected, as the user dev. Maybe the folder already existed from your previous attempt as root?

In any case, chown -R dev:dev /path/to/git/repo should be able to fix it.

EDIT: If this issue only affects git (and not touch XYZ), maybe check Git templates to see if any special hooks are in action. Group ownership may be affected by the setgid bit (e.g., chmod g+s ...), but I don't think there is an equivalent for user ownership.

  • Thank you. See my comment on the other answer. Very strange issue. – Utkanos Aug 11 at 17:53
  • I think config.filemode may explain your file permissions (along with your umask settings), but for the default user/group ownership, it's indeed very weird. I edited my answer to give some places to look into. – Roc White Aug 11 at 19:21

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.