Magit running git commit takes forever

504 Views Asked by At

I am using Emacs on Mac OS with the package Magit. Everything works fine except when I try to do a commit (shortcut: c c). Magit hangs with this message in the bottom bar: "running git commit". What is weird is that when I stop the command (Ctrl-g), magit shows me the buffer to write my commit message and everything works fine. I don't know why this happens.

with-editor-emacsclient-executable

is set to /usr/local/Cellar/emacs/HEAD/bin/emacsclient.

and calling /usr/local/Cellar/emacs/HEAD/bin/emacsclient filename directly from the console seems to work.

Thank you for your help!

1

There are 1 best solutions below

7
On

It seems to be a common problem when dealing with a large repo or a repo that has been around for a long time. Try cleaning up the repo. You can use these:

git remote prune origin
git gc

From the official docs:

git remote prune origin

Deletes all stale remote-tracking branches under name. These stale branches have already been removed from the remote repository referenced by name, but are still locally available in "remotes/name".

git gc

Runs a number of housekeeping tasks within the current repository, such as compressing file revisions (to reduce disk space and increase performance) and removing unreachable objects which may have been created from prior invocations of git add.

Users are encouraged to run this task on a regular basis within each repository to maintain good disk space utilization and good operating performance.

Could be an issue with large diffs too:

https://github.com/magit/magit/issues/2048