-1

image of command line

As mentioned above, I am presented with this error when trying to run

git remote set-url origin x

This error only occurs within WSL and works fine in cmd in windows. Any ideas?

Christian
  • 4,902
  • 4
  • 24
  • 42
cope
  • 11
  • 6
  • This isn't from GitHub (GitHub is not relevant here). The error comes from Git but is due to some sort of misconfiguration of your WSL setup. Note: don't use screenshots of error messages when cut-and-paste would suffice (see [ask]): the tiny font that this winds up using is very hard to read. – torek Sep 18 '22 at 01:02
  • I think it's related to user rights on your windows linux sub system: https://stackoverflow.com/questions/57243299/jekyll-operation-not-permitted-apply2files/57281081#57281081 – Christian Sep 18 '22 at 01:26

2 Answers2

1

This is a WSL bug. In general, when Git writes a new configuration file, it will set the permissions accordingly on the lock file so that when it renames the lock file into place, it has the correct permissions.

However, in this case, WSL says that the chmod system call, which performs this, doesn't work on this file. That's because unlike Linux, which actually just ignores the permissions change on file systems which don't support it, WSL simply refuses to perform the operation and returns an error code when operating on a Windows path.

There's unfortunately no way around this when using a Linux Git on a Windows path, so you need to modify the .git/config file by hand to update the remote URL. Linux distributions are not going to modify their Git implementations to change this since the behaviour is due to WSL, which they don't ship, and this works just fine on Linux itself.

bk2204
  • 64,793
  • 6
  • 84
  • 100
0

Your linux file system does not have write privileges. The following will assign write privilege to the entire contents of your .git folder:

# Assuming you are in the collegework folder
chmod -R +w .git

Then try the command again.

If you receive 'Operation not permitted errors' use the following command instead:

sudo chmod -R +w .git
Akanni
  • 924
  • 9
  • 10
Phillip Ngan
  • 15,482
  • 8
  • 63
  • 79