2

I usually use git-bash to manage source code from my windows desktop. When I am done, I close the git-bash window or run the exit command.

Then, I noticed that a good number of folders used for git projects are locked by git. The only way to release the lock is to kill the git process.

Is there a way close git and all its processes when done using git?

Now, I am using PowerShell to track locked files and kill the related processes:

PS> openfiles /query | find "folder-name"
PS> taskkill /im git.exe

enter image description here

Note: I noticed the file lock using Windows Process Explorer File Handle Search utility. I had to run the utility with Admin privileges for this feature to find the locks. See the snapshot below.

I appreciate your help.

Process Explorer File Handle Search Tarek

tarekahf
  • 738
  • 1
  • 16
  • 42
  • Does this issue also happen when you run the `git` version control tool from a command line with administrative privileges instead of git-bash? – Sercan Jan 07 '22 at 17:29
  • I usually run 'git-bash here' from the right-click options in File Explorer. I didn't check other options such as running git command from CMD. Are you saying if I run git command using other command line windows it will be different? – tarekahf Jan 07 '22 at 17:32
  • 1
    I don't open git-bash when I use git because CMD is in my local right-click menu; I've never had the problem you mention. That's why I asked so I can isolate the problem. – Sercan Jan 07 '22 at 17:38
  • OK, thanks. I will check that next time I use git. – tarekahf Jan 07 '22 at 17:42
  • @Sercan I used CMD.EXE to work with GIT and still the same problem. After I close the CMD Windows, the GIT process is still active and locking a number of folder and I cannot rename or move the folders which are locked. – tarekahf Jan 07 '22 at 18:30
  • Is Git LFS enabled in the project? – Sercan Jan 07 '22 at 18:31
  • I didn't do anything specific for the projects I am working with. I ran the command `git lfs` and got this `git-lfs/2.13.3 (GitHub; windows amd64; go 1.16.2; git a5e65851)` in addition to help text. I never used this feature. – tarekahf Jan 07 '22 at 18:37

1 Answers1

2

Installing a new version of Git for Windows and disabling the file system watcher should fix the directory locking (this affects the core.useBuiltinFSMonitor setting):

Git for Windows fsmonitor

axelstudios
  • 336
  • 3
  • 7