[Github] 이미 삭제한 큰 용량의 파일 때문에 Git Repo에 Push 실패 시

olxtar·2022년 6월 3일
0
post-thumbnail

참고 : https://stackoverflow.com/questions/19573031/cant-push-to-github-because-of-large-file-which-i-already-deleted



Error

!git push -u origin main

>>>
remote: error: Trace: 9526cecc23772d24b60545fac43022cad74ce93421f6ed72b9f35402f74b3966        
remote: error: See http://git.io/iEPt8g for more information.        
remote: error: File weight_init_test.pt is 257.15 MB; this exceeds GitHub's file size limit of 100.00 MB        
remote: error: GH001: Large files detected. You may want to try Git Large File Storage - https://git-lfs.github.com.        
To https://github.com/olxtar/Landmark_Classification.git
 ! [remote rejected] main -> main (pre-receive hook declined)
error: failed to push some refs to 'https://github.com/olxtar/Landmark_Classification.git'


Solution

  1. status를 확인한다. \rightarrow 아래의 출력처럼 4 commits (너가 계속 Push하려고 했던 Commit들... 하지만 Push 되지 않은...) 얘네를 삭제해줘야한다!
!git status

>>>
On branch main
Your branch is ahead of 'origin/main' by 4 commits.
  (use "git push" to publish your local commits)

Changes not staged for commit:
  (use "git add <file>..." to update what will be committed)
  (use "git restore <file>..." to discard changes in working directory)
	modified:   Project2_github.ipynb

no changes added to commit (use "git add" and/or "git commit -a")




  1. !git reset HEAD~0 : 이 명령어로 commit들을 없애준다
    [?]HEAD~0에서의 숫자 0이 commit들의 인덱스인것같다... !git reset HEAD~1 이런식으로 다 삭제해주자...
!git reset HEAD~0

>>>
Unstaged changes after reset:
M	Project2_Landmark_Classification.ipynb
M	Project2_github.ipynb




  1. 마지막으로 status 재확인
    [!] 한개정도는 괜찮나보네... PUSH됨
!git status

>>>
On branch main
Your branch is behind 'origin/main' by 1 commit, and can be fast-forwarded.
  (use "git pull" to update your local branch)

Changes not staged for commit:
  (use "git add <file>..." to update what will be committed)
  (use "git restore <file>..." to discard changes in working directory)
	modified:   Project2_Landmark_Classification.ipynb
	modified:   Project2_github.ipynb

Untracked files:
  (use "git add <file>..." to include in what will be committed)
	.ipynb_checkpoints/

no changes added to commit (use "git add" and/or "git commit -a")
profile
예술과 기술

0개의 댓글