Reputation: 8074
I wanted to checkout an older commit to my working directory to mess around with something so I did the following command in the root of my repo:
git checkout 2aa2c5 .
But nothing happened, the # prompt simply came back. I did the command a few more times, but nothing seemed to happen. I then did:
git status
Which showed that I was still on master
. I then did:
git checkout master
As I wasn't sure what was happening and just wanted to get back to where I was. It came back with Already on master
However now my website is not accessible, every single file now seems to have the permission 644? I am really not sure what has happened? It looks like although my original attempt to checkout a commit didn't do anything, it has messed with my file permissions, and/or file ownership.
UPDATE: I don't think it is the permission that is the problem. I think the problem is that all the files have changed to root for the owner and group? I was logged in as root when I did the checkout, will that have caused this?
I am new to git and Linux file permission in general, if anyone could shed some light on this I would really appreciate it.
Thanks
Upvotes: 1
Views: 2624
Reputation: 328770
Permissions and ownership are really critical for web servers. If you get this wrong, the wrong people (= crackers) can read or modify your files. So make sure you understand what you're doing.
As a rule of thumb, never work as root
. One silly mistake (like a flacky mouse that cut&pastes too much) can cost you the work of many hours.
In your case, it seems that the ownership of the files was changed. To fix this, you will have to delete all the files (as root; be careful - if you make a mistake, a lot more that you might ever want will be gone!)
Try to keep the Git repo (i.e. delete everything except for the .git
folder) but I fear that running git
as root has already messed with some permissions in that folder as well.
So your best bet might be to delete the whole tree (including the .git folder) and clone it again with the correct user.
Related:
Upvotes: 1