If you encounter a problem where you cannot commit changes in Git β neither through the terminal nor via the GitHub Desktop application β the issue might be a freeze during the Git commit process. This is often caused by GPG lock issues. Below is a concise and step-by-step guide to resolve this problem.
Open your terminal and try to perform a GPG operation (like signing a test message). If you see repeated messages like gpg: waiting for lock (held by [process_id]) ...
, it indicates a lock issue.
For example:
β― echo "test" | gpg --clearsign
gpg: waiting for lock (held by 3571) ...
gpg: waiting for lock (held by 3571) ...
gpg: waiting for lock (held by 3571) ...
List Lock Files:
For Linux:
ls -l ~/.gnupg/*.lock
For MacOS (Darwin):
ls -l ~/.gnupg/**/*.lock
This command lists all lockfiles in ~/.gnupg and its subdirectories without manual exploration.
Remove the Identified Stale Lock Files:
For general lock files:
rm ~/.gnupg/[name-of-the-stale-lock-file].lock
For Linux systems, if the above doesn't work, try removing the public keys database lock:
rm -f ~/.gnupg/public-keys.d/pubring.db.lock
After removing any stale lock files, it's important to reset the state of the GPG agent.
Command to Restart GPG-Agent:
gpgconf --reload gpg-agent
To confirm if the issue is with GPG itself, try signing a simple test message:
Run:
echo "test" | gpg --clearsign
With the GPG lock issue resolved, try committing your changes again in Git.
Thanks. Unfortunately, there are no lock files in the listed directory but my database is locked anyway. Did anybody else also have this issue? I'm on Fedora 41.
Edit:
rm -f ~/.gnupg/public-keys.d/pubring.db.lock
worked for me.