Git

Frozen Git Push

In some instances, you might encounter where a specific push that you wish to apply to a remote repo such as GitHub, Gitlab, Bitbucket, or any other hosted Git service becomes frozen and nothing seems to happen.

Although this may not be a common occurrence, it can happen and can be difficult to figure out especially for beginners.

In this tutorial, we will explore the various causes of a frozen “git push” and how we can resolve it to apply the specified push.

Cause 1: Invalid Remote URL

There are various reasons and causes as to why a “git push” might be frozen. However, a common one is if the URL to the remote repository is incorrect.

To resolve this, ensure that you are pushing to the correct remote URL. You can show the remote URL using the following command:

$ git remote show <remote>

To replace the remote URL, you can use the following command:

$ git remote set-url origin git@github.com:username/repo_name.git

Cause 2: SSH Agent Error

Another cause of this error is if you have an issue with your ssh-agent. This can range from the service not responding, an error, etc.

You can resolve this error by attempting to restart the service as shown in the following command:

$ killall ssh-agent; eval `ssh-agent`

Cause 3: Invalid Credentials

The third potential cause of a frozen “git push” is if you are using the incorrect credentials to access the hosting service.

To fix this, you can re-login to the Git hosting service using the command as follows:

$ git login

This prompts you to login to the Git hosting service; this may be GitHub. If we are working with a generic credential manager, we can use the following command to re-login:

$ $ git credential fill --<protocol>://<your-git-host>

Cause 4: File Size Limitations

Another reason that a “git push” may seem frozen is if you are trying to push a large file. You can get the currently configured buffer limit with the following command:

$ git config --get http.postBuffer

The “http.postBuffer” config entry determines the maximum size in bytes of the data that Git will buffer when making HTTP requests. For example, during push or fetch operations over HTTP/HTTPS.

To configure this value in bytes, use the following command:

$ git config --global http.postBuffer 10485760

This should set the max value to 10 MB.

Cause 5: Garbage Collector

Git has a garbage collector that allows Git to optimize and clean up a repository by removing unnecessary objects and optimizing the repo database.

The work of the garbage collector is to help reduce the size of the repo, improve its performance, and ensure that Git performs efficiently.

However, if you have an issue with the garbage collector, tasks such as pushes can fail. To fix and re-run the garbage collector, navigate to the repository directory and run the following command:

$ git gc

This runs the garbage collector manually and perform the optimizations immediately.

Cause 6: Dead Session/Network Error

A last resort that you probably should have checked by now is to ensure that the terminal session is not dead. In some instances, some terminals will kill an inactive session after a given duration to save on resources.

To resolve this, you can recreate a new terminal session. Ensure that your device is connected to the internet.

Conclusion

In this tutorial, we explored the potential causes of a frozen “git push”, why it might occur, and how you can fix it.

About the author

John Otieno

My name is John and am a fellow geek like you. I am passionate about all things computers from Hardware, Operating systems to Programming. My dream is to share my knowledge with the world and help out fellow geeks. Follow my content by subscribing to LinuxHint mailing list