집에서 회사 업무를 하거나 회사에서 개인 Github으로 Commit하고자 할 때 git config 설정이 잘못 되어 있어서 회사 계정으로 commit 하거나 개인 계정으로 commit 되어 버리는 경우가 많다 그때마다 `git config` 설정을 하는게 너무 귀찮고 깜빡할때가 있어서 다른 방법을 찾아보니 Directory별로 설정할 수 있는 방법이 있다! 우선 `.gitconfig` 파일을 들어가 수정한다. `.gitconfig` 파일 위치를 모를 경우 아래와 같이 입력하면 파일 위치를 알 수 있다. 보통은 home 아래에 있다. ``` shell git config --list --show-origin ``` `.gitconfig` 파일을 열어보면 Global로 설정해둔 정보가 입력되어 있다. ``` shell [user] email = user@email.com name = username ``` 우선 위와 같이 설정된 부분을 전부 지운 후 아래와 같이 설정한다. ``` shell [includeIf "gitdir:~/code/personal/"] path = .gitconfig-personal [includeIf "gitdir:~/code/professional/"] path = .gitconfig-professional ``` `includeIf` 부분에는 기준이 되는 Direcotry 명을 기입해준다. 여기서는 `code/personal`은 개인 계정 폴더이고 `code/professional` 은 회사 계정 폴더로 표기했다. 그리고 아래에 `path` 부분에 설정할 config 파일 명을 기입해준다. 이제 마지막으로 `path`로 정의한 config파일 명을 생성하여 config 설정을 해주면 된다. ### .gitconfig-personal ``` shell [user] email = user.personal@users.noreply.github.com # note we use the noreply github mail name = personal_username ``` ### .gitconfig-professional ``` shell [user] email = user.professional@dns.com name = professional_username ``` 이제 끝이다! 해당 폴더에 들어가서 commit을 해보면 설정된 계정으로 commit되는 것을 확인할 수 있다.