개발을 진행하다 보면 git에 민감정보가 올라가는 경우가 있다.
spring:
datasource:
url: jdbc:mysql://localhost:3306/social
username: ?
password: ?
driver-class-name: com.mysql.cj.jdbc.Driver
데이터베이스의 패스워드나 API의 키 등 사용자 정보를 분리해서 작성해보자.
application-db.yml 파일
spring:
datasource:
url: jdbc:mysql://localhost:3306/social
username: user-name
password: user-password
driver-class-name: com.mysql.cj.jdbc.Driver
아래와 같이 application-[] => 괄호안의 이름 포함시키기
spring:
profiles:
include:
- oauth
- db
gitignore파일에 민감정보 파일 포함시키기
이미 민감정보파일을 git에 push했다면
git rm --cached 파일명 => 원격 저장소 파일 삭제
git commit -m "내용"
git push ~ ~
git rm [--cached] 파일명 : --cached 옵션이 있으면 원격 저장소 파일만 아니면 로컬까지 삭제