Today while trying to clone big repository using “git fetch” we encountered following error, “fetching iteration / depth 2” remote: Counting objects: 4, done. remote: Compressing objects: 100% (2/2), done. remote: Total 4 (delta 3), reused 3 (delta 2), pack-reused 0 Unpacking objects: 100% (4/4), done.

Command line execution

Terminalbash
git fetch”  we encountered following error, “fetching iteration / depth 2” remote: Counting objects: 4, done. remote: Compressing objects: 100% (2/2), done. remote: Total 4 (delta 3), reused 3 (delta 2), pack-reused 0 Unpacking objects: 100% (4/4), done. Auto packing the repository in background for optimum performance. See “git help gc” for manual housekeeping. error: The last gc run reported the following. Please correct the root cause and remove .git/gc.log. Automatic cleanup will not be performed until the file is removed. fatal: Unable to create ‘ /home/myuser/my_source_code/ .git/shallow.lock’: File exists. If no other git process is currently running, this probably means a git process crashed in this repository earlier. Make sure no other git process is running and remove the file manually to continue. error: failed to run prune Solution  : Stop git fetch command using ctrl+c  $ rm -rf /home/myuser/my_source_code/.git/shallow.lock  $ rm -rf /home/myuser/my_source_code/.git/gc.log Now start “git fetch” again.

Risk level: destructive. Review the command before running it.

Implementation details

Auto packing the repository in background for optimum performance. See “git help gc” for manual housekeeping. error: The last gc run reported the following. Please correct the root cause and remove .git/gc.log. Automatic cleanup will not be performed until the file is removed.

Gotchas and common issues

  • Permission checks - verify user access rights and sudo privileges before executing system-level operations.

  • Environment configuration - double-check path variables and dependency versions to prevent runtime failures.

  • Backup safeguards - maintain configuration backups before applying system or database modifications.

Following these steps ensures clean configuration and reliable execution for fix – fatal: unable to create ‘.git/shallow.lock’: file exists..