Something has gone awry in your git repository likely caused by an external process creating a file or directory which is owned by a user other than the current user.
This error is common when using Docker, and a service in your docker-compose.yml file has a locally mounted volume which was created using a different user to that of the local machine user.
If this is the first time that this error has occurred, execute the below on your working directory to change the ownership of files and folders back to the logged in user:
sudo chown -R ${USER}:${USER} .
If this is not the first time you have encountered this issue, i.e. you have already committed and pushed files and folders that are owned by another user, then the above alone will not rectify the situation, as well as executing the above command - you will need to carry out the following instructions.
By far, the quickest fix is to execute the following from your root project directory which holds your git repository:
sudo chown -R ${USER}:${USER} .git/objects
To test that everything is fixed, execute the following:
git add .
Quickly followed by executing:
git status
You will see that everything has been added to the git repository without any need to test / fiddle around with anything any further.
touch
new files in.../objects/3f
, or if not, what is its mode? Does.../objects/3f/ce3...
already exist, and if so, what is its mode? Could the partition where/opt
lives be full?