반응형

지난 spring 멀티 모듈프로젝트 구성 후 이것저것 테스트를 하다가

target 폴더 제한하는 방법을 기록해두려한다.

 

뭐 이미 알고 있듯이 .gitignore 파일을 작성하면 된다.

추가로 이미 업로드 된 상태라면 git rm -r --cache [폴더]로 지운 뒤 push 해주면 된다.

 

.gitignore 파일 작성

git clone 후 최상단 경로에 작성해야 한다.

# ignore properties file
test/core/target
test/market/target
test/target/

.metadata
test/.settings
test/core/.settings
test/market/.settings

적당히 target 과 .settings / .metadata 폴더를 제외시켰다.

참고로 필자의 폴더구조는 아래와 같다.(window cmd 명령어)

> tree | findstr /v /r /c:"^........│" /c:"^│....... "
└─test
    ├─.settings
    ├─core
    │  ├─.settings
    │  ├─src
    │  └─target
    │      ├─classes
    │      │  ├─com
    │      │  │  └─joon95
    │      │  │      └─test
    │      │  │          └─core
    │      │  │              ├─controller
    │      │  │              ├─monster
    │      │  │              ├─repository
    │      │  │              ├─service
    │      │  │              └─vo
    │      │  ├─META-INF
    │      │  │  └─maven
    │      │  │      └─org.springframework.boot
    │      │  │          └─core
    │      │  └─static
    │      │      ├─css
    │      │      └─html
    │      ├─generated-sources
    │      │  └─annotations
    │      ├─generated-test-sources
    │      │  └─test-annotations
    │      └─test-classes
    ├─market
    │  ├─.settings
    │  ├─src
    │  └─target
    │      ├─classes
    │      │  ├─com
    │      │  │  └─joon95
    │      │  │      └─test
    │      │  │          └─market
    │      │  │              └─stage
    │      │  └─META-INF
    │      │      └─maven
    │      │          └─com.joon95
    │      │              └─market
    │      ├─generated-sources
    │      │  └─annotations
    │      ├─generated-test-sources
    │      │  └─test-annotations
    │      └─test-classes
    └─target
        └─classes
            └─META-INF
                └─maven
                    └─com.joon95
                        └─test

 

기존 업로드된 폴더 제거

필자는 이미 target 폴더 외 모든 폴더를 commit & push 해놓았다.

이 상태로는 .gitignore 파일이 생겨도 기존 폴더를 삭제하지 않는다.

 

그래서 git cache를 날려 폴더나 파일을 삭제해야한다.

필자는 1번에 모든 폴더를 날려버리고 진행했다.

$ git rm -r --cached .
더보기

rm '.gitignore'
rm 'README.md'
rm 'test/.classpath'
rm 'test/.gitignore'
rm 'test/.project'
rm 'test/.settings/org.eclipse.core.resources.prefs'
rm 'test/.settings/org.eclipse.jdt.apt.core.prefs'
rm 'test/.settings/org.eclipse.jdt.core.prefs'
rm 'test/.settings/org.eclipse.m2e.core.prefs'
rm 'test/core/.classpath'
rm 'test/core/.project'
rm 'test/core/.settings/org.eclipse.core.resources.prefs'
rm 'test/core/.settings/org.eclipse.jdt.apt.core.prefs'
rm 'test/core/.settings/org.eclipse.jdt.core.prefs'
rm 'test/core/.settings/org.eclipse.m2e.core.prefs'
rm 'test/core/.settings/org.springframework.ide.eclipse.prefs'
rm 'test/core/Dockerfile'
rm 'test/core/pom.xml'
rm 'test/core/src/main/java/com/joon95/test/core/Application.java'
rm 'test/core/src/main/java/com/joon95/test/core/AuthInterceptor.java'
rm 'test/core/src/main/java/com/joon95/test/core/RedisConfig'
rm 'test/core/src/main/java/com/joon95/test/core/SpringSecurity.java'
rm 'test/core/src/main/java/com/joon95/test/core/WebMvcConfig.java'
rm 'test/core/src/main/java/com/joon95/test/core/controller/UserController.java'
rm 'test/core/src/main/java/com/joon95/test/core/monster/MonsterController.java'
rm 'test/core/src/main/java/com/joon95/test/core/repository/UserRepository.java'
rm 'test/core/src/main/java/com/joon95/test/core/service/UserService.java'
rm 'test/core/src/main/java/com/joon95/test/core/vo/Sample.java'
rm 'test/core/src/main/java/com/joon95/test/core/vo/User.java'
rm 'test/core/src/main/resources/application-local.properties'
rm 'test/core/src/main/resources/application-master.properties'
rm 'test/core/src/main/resources/application.properties'
rm 'test/core/src/main/resources/static/css/bootstrap.min.css'
rm 'test/core/src/main/resources/static/css/style.css'
rm 'test/core/src/main/resources/static/html/add.html'
rm 'test/core/src/main/resources/static/html/item.html'
rm 'test/core/src/main/resources/static/html/items.html'
rm 'test/core/src/main/resources/static/index.html'
rm 'test/core/target/classes/META-INF/MANIFEST.MF'
rm 'test/core/target/classes/META-INF/maven/com.joon95/core/pom.properties'
rm 'test/core/target/classes/META-INF/maven/com.joon95/core/pom.xml'
rm 'test/core/target/classes/application-local.properties'
rm 'test/core/target/classes/application.properties'
rm 'test/core/target/classes/com/joon95/test/core/Application.class'
rm 'test/core/target/classes/com/joon95/test/core/AuthInterceptor.class'
rm 'test/core/target/classes/com/joon95/test/core/SpringSecurity.class'
rm 'test/core/target/classes/com/joon95/test/core/WebMvcConfig.class'
rm 'test/core/target/classes/com/joon95/test/core/controller/UserController.class'
rm 'test/core/target/classes/com/joon95/test/core/monster/MonsterController.class'
rm 'test/core/target/classes/com/joon95/test/core/repository/UserRepository.class'
rm 'test/core/target/classes/com/joon95/test/core/service/UserService.class'
rm 'test/core/target/classes/com/joon95/test/core/vo/Sample.class'
rm 'test/core/target/classes/com/joon95/test/core/vo/User.class'
rm 'test/core/target/classes/static/css/bootstrap.min.css'
rm 'test/core/target/classes/static/css/style.css'
rm 'test/core/target/classes/static/html/add.html'
rm 'test/core/target/classes/static/html/item.html'
rm 'test/core/target/classes/static/html/items.html'
rm 'test/core/target/classes/static/index.html'
rm 'test/core/target/core-0.0.1-SNAPSHOT.jar'
rm 'test/core/target/core-0.0.1-SNAPSHOT.jar.original'
rm 'test/core/target/maven-archiver/pom.properties'
rm 'test/core/target/maven-status/maven-compiler-plugin/compile/default-compile/createdFiles.lst'
rm 'test/core/target/maven-status/maven-compiler-plugin/compile/default-compile/inputFiles.lst'
rm 'test/core/target/maven-status/maven-compiler-plugin/testCompile/default-testCompile/createdFiles.lst'
rm 'test/core/target/maven-status/maven-compiler-plugin/testCompile/default-testCompile/inputFiles.lst'
rm 'test/market/.classpath'
rm 'test/market/.project'
rm 'test/market/.settings/org.eclipse.core.resources.prefs'
rm 'test/market/.settings/org.eclipse.jdt.apt.core.prefs'
rm 'test/market/.settings/org.eclipse.jdt.core.prefs'
rm 'test/market/.settings/org.eclipse.m2e.core.prefs'
rm 'test/market/.settings/org.springframework.ide.eclipse.prefs'
rm 'test/market/pom.xml'
rm 'test/market/src/main/java/com/joon95/test/market/Application.java'
rm 'test/market/src/main/java/com/joon95/test/market/stage/StageController.java'
rm 'test/market/src/main/resources/application.properties'
rm 'test/market/target/classes/META-INF/MANIFEST.MF'
rm 'test/market/target/classes/META-INF/maven/com.joon95/market/pom.properties'
rm 'test/market/target/classes/META-INF/maven/com.joon95/market/pom.xml'
rm 'test/market/target/classes/application.properties'
rm 'test/market/target/classes/com/joon95/test/market/Application.class'
rm 'test/market/target/classes/com/joon95/test/market/stage/StageController.class'
rm 'test/pom.xml'
rm 'test/target/classes/META-INF/MANIFEST.MF'
rm 'test/target/classes/META-INF/maven/com.joon95/test/pom.properties'
rm 'test/target/classes/META-INF/maven/com.joon95/test/pom.xml'

물론 . 을 쓰지않고 파일명이나 폴더명을 입력해서 삭제할 수 있다.

 

삭제가 되었으면 add & commit & push 하자.

$ git add .
$ git commit -m "ignore 파일제외 적용"
$ git push

 

필자는 네이버클라우드의 git인 SourceCommit 에서 테스트중이다.

ncp SourceCommit (Git)

이제 깔끔하게 지워진 레포지토리를 구경할 수 있다.

반응형

'개발 > 기타' 카테고리의 다른 글

Golang Test Standard  (1) 2024.10.10
[Eclipse] Lombok 적용하기  (0) 2022.10.07
[유전자분석] IGV 라이브러리 사용하기  (0) 2022.10.06
복사했습니다!