During git mv (rename): “unable to unlink old” “invalid argument”
Posted by jpluimers on 2019/03/20
I had an error when doing a rename (mv) in git “unable to unlink old” “invalid argument”. This appeared to be a process having a lock on that file.
In my case, this was a bit hard to track down (I used Process Explorer for it), as the culprit was SourceTree running git in the background to keep an eye on changes in the repository because it has a file system watcher on the repository tree and a different process was writing log files in the same directory structure.
Can you still follow? I had a hard time so here it is in manageable bits:
- By default SourceTree has a file system watcher on your repositories
- If that watcher fires, SourceTree runs a background git process to get the current state of the repository
- If you perform UI actions, SourceTree runs a foreground git process to perform the action
- SourceTree does not have a mechanism to wait for the background git process to finish before running the foreground process
- I had had another process running that logged into a relative directory that happened to be within the repository tree (but using files excluded by .gitignore)
Basically SourceTree should do two things:
- keep track of the background process and not fire a foreground one
- do not start the background process for files excluded by .gitignore
I tracked down what happened using these tips:
- [WayBack] moodle – GIT pull failed: ‘unable to unlink file: invalid argument’ – Stack Overflow
- [WayBack] tortoisegit – Git error – unable to unlink old ‘some/file/name’ (Bad file descriptor) – Stack Overflow
- [WayBack] filesystems – Find out which process is locking a file or folder in Windows – Super User
–jeroen
Leave a Reply