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.

Leave a Comment

1 comment

  1. G

    This is an amazing Git feature. Glad to read about. I always thought, this was basic Linux/Unix file permission/ownership stuff, but now I see the real clue behind. Never thought this could happen with a tool like Git, though, which was originally invented by Linus Torvalds himself.

By continuing to use the site, you agree to the use of cookies. more information

The cookie settings on this website are set to "allow cookies" to give you the best browsing experience possible. If you continue to use this website without changing your cookie settings or you click "Accept" below then you are consenting to this.

Close