Git Repository에  Upload하면 안되는 파일/폴더를 Upload한 상황 (ex. 보안키, Build output 등...)

나는 Build Output을 업로드 하는 바람에 object파일들과 그외 의존성파일들이 함께 업로드 되었다😢

gitignore파일을 같이올리면 원본 코드도 안올라갈까봐 제외하고 올린후에 나중에 한번에 올렸는데,

gitignore에서 무시해야했던 빌드 결과들이 이미 올라가버린것;;; 

이럴거면 gitignore을 먼저 올리고 나중에 원본코드를 올리는게 맞았던것같다...

 

git filter-branch

git filter-branch --tree-filter 를 사용하여 Git(history에서도)과 Local에서 삭제할수있다.

 

$ git filter-branch --tree-filter 'rm -f 경로' HEAD

$ git push -f origin master

++ 삭제해야할 내용이 '폴더'이면 rm -f에 'r'옵션을 추가한다.

 

push 해야 하는 파일이 큰 경우

그러나 커밋하나당 5GB를 꽉꽉 채워서 Upload했었기 때문에 한번에 push하는데 Error 발생

remote: Analyzing objects... (498974/863067)
error: 리모트 묶음 풀기 실패: error TF402462: This push was rejected because its size is greater than the 5120 MB limit for pushes in this repository. 
Learn more at https://aka.ms/gitlimit To https://~~~
![remote rejected]       master -> master (TF402462: This push was rejected because its size is greater than the 5120 MB limit for pushes in this repository. Learn more at https://aka.ms/gitlimit)
error: 레퍼런스를 'https://~~'에 푸시하는데 실패했습니다

 

push 작업을 commit 하나하나를 단계적으로 하는 방법으로 했다. (시간이 굉장히 오래걸렸..걸리는중이다.)

$ git push <remotename> <commit SHA>:<remotebranchname>

https://stackoverflow.com/questions/3230074/how-can-i-push-a-specific-commit-to-a-remote-and-not-previous-commits

 

How can I push a specific commit to a remote, and not previous commits?

I have made several commits on different files, but so far I would like to push to my remote repository only a specific commit. Is that possible?

stackoverflow.com

 

git filter-branch 되돌리기

git filter-branch 명령어는 자동으로 backup을 수행한다 👍

$ git reset --hard refs/original/refs/heads/master

 

참고 사이트

https://www.dsaint31.me/etc/etc-git-filter-branch/

 

[Etc] Git에서 파일 완전삭제

파일의 모든 commit에서 영구적 삭제@(Computer)

www.dsaint31.me

 

+ Recent posts