Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why is the Commit operation taking forever in Visual Studio Code?

When trying to 'commit' files the process just loads and loads but never completes.

enter image description here

These are the steps I followed:

  1. I installed "Git"

  2. Created a repository for my files and then put some random files in there

  3. Opened VS Code and opened my repository folder

  4. Navigated to "Source Control"

  5. Staged my documents (I didn't actually make any changes to the files but I just wanted to test it out since it's my first time using the tool).

  6. Clicked "Commit"

  7. When I clicked "Commit" I got an error which read:

    "Make sure you configure your 'user.name' and 'user.email' in git."

  8. I found this link on Stack Overflow: "Make sure you configure your 'user.email' and 'user.name' in git" when trying to push to git lab, and using that link, I opened the terminal and typed:

    git config --global user.name "My name"
    
    git config --global user.email "myemail"
    

    Please see the image below:

    enter image description here

  9. I then clicked 'Commit', it began running but it just loaded indefinitely and never completed.

Does anyone know how I can fix this problem?.

I really tried to find a solution online. People suggested updating Visual Studio Code, fortunately mine is already up to date.

like image 372
HamidBee Avatar asked Dec 13 '25 10:12

HamidBee


2 Answers

I have no idea why Git does this. It happens to me occasionally, but there are some solutions.

First, restart Visual Studio Code. Then try to commit & push again. If it still doesn't work, restart it again and this time, don't forget to write a message while committing.

You can also do

git commit -m 'message'

as it sometimes works. You can try that too.

I mostly experience this issue when I forget to write a message while committing or when there is an update to Git.

like image 178
EmpeRa Avatar answered Dec 15 '25 14:12

EmpeRa


This happened to me when I forgot to write a commit message.

When git is run without a commit message it will open an editor to allow for longer messages, thus leading to it hanging forever.

If on Linux you can open htop, search for git and kill the process, not sure how that would be done on Windows.

like image 34
nullpo1nt3r Avatar answered Dec 15 '25 13:12

nullpo1nt3r