'Unable to repo sync cyanogenmod source stuck at 99%

Fetching projects:  97% (505/520)  Fetching project CyanogenMod/android_hardware_qcom_media
Fetching project CyanogenMod/android_hardware_qcom_audio
fatal: Couldn't find remote ref refs/heads/stable/cm-13.0-ZNH2KB
Unexpected end of command stream
Fetching project CyanogenMod/android_hardware_qcom_media
Fetching project CyanogenMod/android_hardware_qcom_audio
Fetching project CyanogenMod/android_hardware_qcom_media
Fetching projects:  98% (510/520)  Fetching project CyanogenMod/android_hardware_qcom_audio
fatal: Couldn't find remote ref refs/heads/stable/cm-13.0-ZNH2KB
Unexpected end of command stream
Fetching project CyanogenMod/android_hardware_qcom_media
Fetching project CyanogenMod/android_hardware_qcom_audio
Fetching project CyanogenMod/android_hardware_qcom_media
Fetching projects:  99% (515/520)  Fetching project CyanogenMod/android_hardware_qcom_media
fatal: Couldn't find remote ref refs/heads/stable/cm-13.0-ZNH2KB
Unexpected end of command stream
fatal: Couldn't find remote ref refs/heads/stable/cm-13.0-ZNH2KB
Unexpected end of command stream
error: Cannot fetch CyanogenMod/android_device_qcom_sepolicy
error: Cannot fetch CyanogenMod/android_vendor_qcom_opensource_dataservices
error: Cannot fetch CyanogenMod/android_vendor_qcom_opensource_time-services
error: Cannot fetch CyanogenMod/android_vendor_qcom_opensource_dpm

error: Exited sync due to fetch errors


Solution 1:[1]

Use--force-broken or -f to recover from network errors.

So, use repo sync like this:

repo sync -j8 -f

If you still get errors, add a comment.

Solution 2:[2]

Difficulties syncing the source tree (TCP issues) Symptom: repo sync hangs while syncing, often when it's completed 99% of the sync.

Cause: Some settings in the TCP/IP stack cause difficulties in some network environments, so that repo sync neither completes nor fails.

Fix: On Linux, enter the command:

sysctl -w net.ipv4.tcp_window_scaling=0

On macOS, disable the rfc1323 extension in the network settings.

https://source.android.com/setup/build/known-issues

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1
Solution 2 glenn