Git Push卡住并出现Bad File Descriptor问题求助
Git Push Stuck After "Writing objects: 100%" in Single Repository
Problem Details
- Issue occurs only in a single Git repository
git pushgets stuck immediately after outputting:Writing objects: 100% (823/823), 73.56 MiB | 34.07 MiB/s, done. Total 823 (delta 522), reused 752 (delta 454), pack-reused 0- Adjusting buffer with
git config --global pack.windowMemory "32m"improved transfer speed but did not resolve the stuck issue strace -efile -f git pushoutput shows:Writing objects: 100% (823/823), 73.56 MiB | 34.07 MiB/s, done. Total 823 (delta 522), reused 752 (delta 454), pack-reused 0 [pid 2380] newfstatat(1, "", 0x7ffea1c08270, AT_EMPTY_PATH) = -1 EBADF (Bad file descriptor) [pid 2380] +++ exited with 0 +++ [pid 2375] --- SIGCHLD {si_signo=SIGCHLD, si_code=CLD_EXITED, si_pid=2380, si_uid=1000, si_status=0, si_utime=70 /* 0.70 s */, si_stime=20 /* 0.20 s */}
Troubleshooting & Solutions
1. Reset Remote Connection
- Remove and re-add the remote origin to fix potential connection corruption:
git remote remove origin git remote add origin <your-remote-repo-url> - Pull latest changes to avoid conflicts before pushing:
git pull origin <your-branch-name> --rebase
2. Repair Local Repository Corruption
Single-repository issues often stem from local repo damage. Run these commands to fix:
- Clean up local cache aggressively:
git gc --prune=now --aggressive - Check for and repair repo integrity issues:
Ifgit fsck --fullgit fsckreports errors, re-cloning the repository is the most reliable fix (back up uncommitted changes first).
3. Disable Progress Output
The EBADF error suggests a problem with stdout/stderr handling. Try pushing without progress output:
git push --no-progress
If this succeeds, configure the repo to disable progress by default:
git config --local transfer.hideProgress true git config --local core.compression 0
4. Fix File Descriptor Issues
EBADF indicates an invalid file descriptor. Try these steps:
- Open a new terminal window and re-run
git push(current shell environment may be corrupted) - Check current file descriptor limits:
ulimit -n - Temporarily raise the limit if it's too low:
Then attempt the push again.ulimit -n 10240
5. Re-clone the Repository
If all else fails:
- Stash or back up uncommitted changes:
git stash push -m "temp backup" - Delete the local repo and re-clone from remote:
rm -rf <your-local-repo-dir> git clone <your-remote-repo-url> - Restore your changes and push:
git stash pop git push
内容的提问来源于stack exchange,提问作者user2609605
相关产品推荐
相关产品推荐

