🐈‍⬛

Git 500/502 error handling

2024/07/01に公開

1. Error detail

When I pushed huge files to git, I got this error:

error: RPC failed; HTTP 500 curl 22 The requested URL returned error:
fatal: the remote end hung up unexpectedly

Q: Why is this happen?
A: File size over the limit.

Q: How to fix?
A: Add, commit and push them separately.

2. How to cancel the commit

2.1 Cancel "git commit"

git reset --soft HEAD~1

This will remain your changes on stage, you can change the number 1 to any number, that is number of cancel the commit. I reccomend this one.
If you undo commit completely, can use this:

git reset --hard HEAD~1

2.2 Cancel "git add"

You can use git reset HEAD <filename> when you wanna unstage files, or use below to unstage all files.

git reset HEAD

After these, you can re-add and commit and push with small units to avoid error.

Discussion