gitgithubdebiangit-pull

How to git remote add on a new device without fatal: detected dubious ownership in repository


I have a setup with github that i was using to move the code efficiently to my raspberry Pi. I'm coding on my windows machine, then pushing it to github, and on my raspberry pi I would just git pull origin master to update the code there and run it there.

The problem is that i have seen a lot of tutos on github and i still have some difficulties doing some setups.

And the problem is that the server updated so all of the setup is lost and I can't find any tuto matching my case.

I already have all of my files on the server (except that my last push is not pulled there), and I would like to link those file again to github. I tried doing git remote add origin but i fell on an error : fatal: detected dubious ownership in repository at '/home/daeltam/Daeltam/PyfDownloadTool' (PyfDownloadTool is the folder containing the server files)

And i can't find any way to to the setup correctly... Any help please ?

Note1: maybe the best thing would be to delete the local files and reinstall all of them but I don't like this idea as there is a few local files not in the github so i would have to be careful not deleting any local-only file.

Note2: the server is under Debian 12.


Solution

  • This seems to be a permissions issue. I believe the owner of the files contained in your PyfDownloadTool directory does not match the user on your terminal.

    You can verify that by running ls -l. Check if the user listed as owner for the files matches the same user returned by whoami.

    In case those differ from each other, you'll want to make changes so they match.

    Alternative 1:

    To update the files permissions owner to match the current user in the terminal, run:

    sudo chown -R $(whoami) .
    

    Alternative 2:

    If the user returned by $whomai differs from what you expect (maybe you're accessing it as root?), change it to the proper user:

    sudo su - <username>