remove .git/HEAD.lock before git fetch
This is a general Merge Request template. Consider to choose a template from the list above if it will match your case more.
What does this MR do?
Remove .git/HEAD.lock
before git fetch
.
Why was this MR needed?
If .git/HEAD.lock
file exists git fetch
failed with the following error:
Fetching changes...
error: update_ref failed for ref 'HEAD': cannot lock ref 'HEAD': Unable to create 'PATH_TO_REPO/.git/HEAD.lock': File exists.
Another git process seems to be running in this repository, e.g.
an editor opened by 'git commit'. Please make sure all processes
are terminated then try again. If it still fails, a git process
may have crashed in this repository earlier:
remove the file manually to continue.
In gitlab-runner .git/HEAD.lock
can be left on disk when job cancelled manually on git checkout
step:
Checking out ed26b205 as master...
ERROR: Job failed: canceled
It can happen with any repository, but more often in large repositories with many changes between git fetch
calls.
Even worse, all subsequent jobs for this working copy on this runner will be failed until .git/HEAD.lock
will not be deleted manually.
Are there points in the code the reviewer needs to double check?
Does this MR meet the acceptance criteria?
-
Documentation created/updated - Tests
-
Added for this feature/bug -
All builds are passing
-
-
Branch has no merge conflicts with master
(if you do - rebase it please)
What are the relevant issue numbers?
Edited by Vitaliy Zakharov