[EDIT]: This has been resolved, see below
I have a folder scripts, in which I have a bash script under git version control.
ls -al
yields
drwxrwxrwx 1 me me 512 Jan 21 16:06 .
drwxrwxrwx 1 me me 512 Jan 23 05:34 ..
-rwxrwxrwx 0 me me 1427 Jan 31 08:08 update_db.sh
I want to unset the changes, so naturally, I do git checkout -- scripts/
. But I get the following error:
error: unable to unlink old 'scripts/update_db.sh': No such file or directory
So I tried the following:
- check out temporary branch, hard reset
git checkout -b tmp
git reset --hard master
resulting in
error: unable to unlink old 'scripts/update_db.sh': No such file or directory
fatal: Could not reset index file to revision 'master'.
OK, so I search for that and find this SO post
This leads me to try and fix the permissions (though it looks like I have the correct permissions on both the file and its parent directory [see above]).
I ran sudo chmod -R ug+w scripts;
on the directory and tried repeating the above, with the same result...
I can't seem to do anything from the Windows Explorer either (saying I lack permissions). I should also note I ran rm scripts/update_db.sh
rm: cannot remove 'scripts/update_db.sh': No such file or directory
Any help would be greatly appreciated!
Solution I didn't think this had anything to do with the terminal I was using, but it appears that may have been the problem. I've been using open-wsl and that appears to not have granted me the correct permissions for the Ubuntu user.
Since the permissions are defined by the user starting the process, I'm guessing that open-wsl was somehow not actually being started as root user, and therefore couldn't delete. And somehow, I'm guessing the file was created by my Linux user having been launched with root permissions, meaning that my open-wsl user and my windows user would both be unable to alter it.
Anyways, that's just my theory, I'm still not fully sure what happened here, but it was resolve by launching the Ubuntu shell from the Windows start menu as a root user, navigating to the directory, and rm
'ing as usual.¯\_(ツ)_/¯