To resolve errors like
warning: suboptimal pack – out of memory
fatal: Out of memory, malloc failed)
error: pack-objects died with strange error

Please assign git memory more i.e 128 or 256 with following command

git config --global pack.windowMemory 256m

this will allocate more memory to git and it will run smoothly.