Dev/Git

[Git] push error - unpack failed: index-pack abnormal exit

창문닦이 2019. 12. 31. 02:19

github로 push가 안되는 문제 발생. cmd 와 sts 플러그인 모두 push 반영이 안되었다.

 

오류 메세지

$ git push
Enumerating objects: 10, done.
Counting objects: 100% (10/10), done.
Delta compression using up to 4 threads
Compressing objects: 100% (5/5), done.
Writing objects: 100% (6/6), 700 bytes | 77.00 KiB/s, done.
Total 6 (delta 3), reused 0 (delta 0)
remote: error: object 커밋해쉬번호: nullSha1: contains entries pointing to null sha1
remote: fatal: fsck error in packed object
error: remote unpack failed: index-pack abnormal exit
To https://github.com/내깃헙주소
 ! [remote rejected] master -> master (failed)
error: failed to push some refs to https://github.com/내깃헙주소'

권한 설정으로 해결해보려 했으나 실패

chown -R 계정 ./objects

https://stackoverflow.com/questions/6321742/how-to-fix-permission-denied-for-git-directory-when-performing-git-push

 

구글링을 통해 SSH 문제인 것을 확인

https://stackoverflow.com/questions/35629118/git-push-error-unpack-failed-index-pack-abnormal-exit

 

경로변경을 안하고 그대로 진행하니 캐싱 삭제 안됨.  

$ git filter-branch --index-filter 'git rm -r --cached --ignore-unmatch modules/sudo' --prune-empty --tag-name-filter cat -- --all

문제가 발생한 커밋번호와 디렉토리 재확인

$ git ls-tree <오류가 발생하는 커밋 해쉬넘버>

인덱스 추가와 커밋이 안되서 진행안됨

$ git filter-branch --index-filter 'git rm -r --cached --ignore-unmatch Chapter06/Chapter06' --prune-empty --tag-name-filter cat -- --all

인덱스 반영

$ git add .

커밋 

$ git commit -m "원하는 커밋 메세지"

경로 제대로 반영하여 재시도하니 정상처리 된 후 push 진행.

$ git filter-branch --index-filter 'git rm -r --cached --ignore-unmatch Chapter06/Chapter06' --prune-empty --tag-name-filter cat -- --all

$ git push

 

 

큰 도움을 준 포스팅
I was able to finally solve this issue. Here is what I did to solve it:
In article https://help.github.com/articles/remove-sensitive-data there is a heading for Purge the file from your repo. I following their example for removing the Rakefile but used the problematic folder instead:
git filter-branch --index-filter 'git rm -r --cached --ignore-unmatch modules/sudo' --prune-empty --tag-name-filter cat -- --all
Since the problematic tree was a folder I added -r to the command. The result was a cleanup of all the commits for the sudo modiles and thus, object 15abe3addde5ad5f7d25e8f0f220d2e9faf3cb22 disappeared! After a commit of the changes, the push was successful. I was able to later re-add the broken module without issue.

출처: <https://stackoverflow.com/questions/12658838/git-error-when-pushing-object-15abe3addde5ad5f7d25e8f0f220d2e9faf3cb22contains/14739771#14739771>