git push
troubleshooting
git issues
version control
software development

git push hangs after Total line

Interview Questions practice on Codemia

Over 8,000 real interview questions from top companies, searchable by company and role.

Browse interview questions

Git is a widely-used version control system essential for managing source code in software development. However, one issue developers sometimes face is the git push operation hanging indefinitely after displaying a "Total" line. Understanding why this happens and how to address it involves diving into Git’s internal workings, network configurations, and, occasionally, disk performance.

Understanding the Issue

What Happens?

After executing a git push, Git calculates and displays the objects to be sent and outputs a line similar to:

  • Latency and Bandwidth: A significant cause of hanging is poor network connectivity. If bandwidth is low or there is high latency, the git push operation may appear to hang while it waits for data packets to be transferred successfully.
  • Pre-receive and Update Hooks: Git allows specifying server-side hooks that run during a push operation. If these hooks are computationally expensive or require resources that are temporarily unavailable, the push may hang.
  • SSH Key Issues: When using SSH for authentication, any problem with the key (e.g., passphrase input prompt not appearing correctly in some GUI environments) could cause a hang.
  • Server Disk I/O: Slow disk performance on the server where the repository is hosted can delay writing objects, which results in perceived hanging.
  • Large Repositories: Particularly large pushes or repositories with unoptimized loose objects can drastically increase the amount of data git has to process, leading to long processing times that appear as hangs.
  • Use tools like ping and traceroute to diagnose the quality and path of the network connection to the Git server.
  • If server access is available, checking server-side logs for any errors or unusual activity when the push operation is initiated can provide insight.
  • If possible, temporarily disable Git hooks to determine if they are the cause.
  • Break large changes into smaller, more frequent commits and pushes.
  • Run git gc and git repack commands to optimize the repository's storage, reducing the size of the data being pushed.
  • If using SSH and encountering issues, consider switching to HTTPS to rule out SSH-specific problems.
  • Consider optimizing the network connection quality and ensuring adequate bandwidth for operations.
  • If server resources (CPU, RAM, Disk I/O) are insufficient, consider scaling them to accommodate Git operations effectively.

Related reading
Free course
Beginner
7 lessons
2 hours
Tackling System Design Interview Problems

A short course that equips you with the skills to approach system design interviews methodically.

Start the free course
Track what you have practised

A free account saves your progress, solutions and study plan across every problem on Codemia.

Interview Questions practice on Codemia

Over 8,000 real interview questions from top companies, searchable by company and role.

Browse interview questions

All Rights Reserved.