-
[git] remote branch에 올라간 파일 제거공부/git 2024. 5. 19. 14:43
git remote 브랜치에는 gitignore 파일이 올라가면 안 됩니다.
하지만 실수로 설정을 잘못하거나 예상치 못한 파일들이 올라가는 경우 기록이 남을 수 있는데 이 부분을 제거하는 방법이 필요합니다.
오늘은 remote branch에 올라간 파일을 제거하는 방법을 말하려 합니다.
1. 제거하고 싶은 파일이나 폴더를 확인
(저의 경우 gradle 파일이었습니다.)
2. CLI 사용
# 1. 특정 파일 제거 git rm --cache [파일명] # ex) git rm --cache src/main/generated/board/entity/QBoard.java # 2. 폴더 하위의 모든 파일 제거 git rm --cache -r [파일명] # ex) git rm --cache -r src/main/generated
명령어를 입력하면
3. remote branch에 commit과 push 진행
4. github에 접속하여 파일이 제거됐는지 확인!!!!
Ref.
https://makemethink.tistory.com/163
[GitHub] remote에 이미 push한 파일 지우기
.gitignore 파일을 설정해 놓지 않아 올라간 .metadata 파일을 지워보려고 한다. 파일을 삭제하는 방법에는 두 가지가 있다. // local $ git rm [File Name] // remote $ git rm –-cached [File Name] 상단의 명령어는 로
makemethink.tistory.com
검색하며 찾아보고 작성한 글입니다. 혹시라도 부정확한 정보를 전달드릴 수 있습니다. 틀린 부분이 있으면 댓글을 남겨주세요.
'공부 > git' 카테고리의 다른 글
[git] 터미널 설정(git branch 명령어 입력시 화면전환 ) (0) 2023.09.07 [gitlab] gitlab ssh key 생성 (0) 2023.08.25 [Error] git 에러 : cannot lock ref 'refs/heads/new-branch': 'refs/heads/exists-branch' exists; cannot create 'refs/heads/new-branch’ (0) 2023.08.22 [Git] your local changes to the following files would be overwritten by merge 오류 (0) 2023.08.20 Github Action을 이용한 ECS에 자동 배포 (0) 2023.06.03