Error: unable to unlink old '$fileName': Invalid argument

error: unable to unlink old '$FileName': Invalid argument

There are many scenarios in which this error gets generated. You might face this error while using sourcetree or git console to push, pull, branch checkout, etc. operations.

I was doing bug fix in older release branch. For that, First I did checkout the release branch in which I want to check-in. After doing it, When I tried to go back to develop branch it was throwing error: unable to unlink old 'FileName': Invalid argument.

error: unable to unlink old '$FileName': Invalid argument
fatal: Could not reset index file to revision '$SHA'.

Now it was like deadlock, I wasn't able to take pull, push, branch switch, discard file, remove file, stash files or any other action.

Solution:
Later I realized the reason behind the error unable to unlink file. Some of files were locked by other applications, because of that SourceTree leaves the repository in a mixed state. Which will not allow Git / SourceTree to do write action on it.

To resolve this issue, identify the files which are locked and by which application It was locked. Try to close that application after saving your current work.

Post a Comment

0 Comments