Git is really an awesome tool, but today I stumbled to an awkward situation after executing git's stash pop command. What happened was that before executing the git command I switched to the root user (sudo -s) for executing some apt-get operations. And forgot to change back to my normal user.
I noticed something was not right when I tried to create a new class in Eclipse IDE. I was getting the error message “Parent of resource is marked as ‘read-only’“. For more than 10 years of using Eclipse IDE I never saw such error message. Still I was quick enough to realize that most likely something is wrong with the permissions of the folder I am trying to create the class in. And I was almost right, the folder in fact had the correct permissions, but ownership of the folder was assigned to the root user/group.
What happened? Well apparently running the git stash pop command as root user placed all files and folder on the file system with root ownership as well. As a result I could not create any new class in folder that was touched by the stashing and I was also unable to run any git command that would do something to with the files with changed ownership.
So if you ever have the similar problem the solution is to change the ownership of all files in your git repository back to your normal user . For this you can use the following command:
sudo chown -R username folder
The command will recursively give ownership of all files and sub-folders in the specified folder to the given user.