If you get errors such as
fatal: Out of memory, malloc failed
error: pack-objects died with strange error
error: failed to push some refs to ?firstname.lastname@example.org:foo.git?
first, upgrade git to the latest version on both ends, then check if
still works. If not, you might have a local issue.
If repack still works, your remote server (the server you push to) might actually run out of memory, which can easily happen with for example smallish VPS slices. So, just increase your swap file as Linus suggests, like this and it might start working again. Hope it helps.