728x90
반응형

안녕하세요 🙇🏻‍♂️

오랜만입니다.. 허허

사이드 프로젝트, 회사 일에 치여 살다보니 포스팅이 많이 밀렸네요

다시 열심히 포스팅 해보는 욱승이 되겠습니다ㅋㅋ (시즌 38492호 다짐)

 

만약 코드나 글이 보이지 않는다면 블로그 우측 하단에 테마를 변경해주세요!!

진짜로요ㅋㅋ

 


 

어쩌다보니 한개의 노트북에서 두개의 프로젝트에 커밋 할 일이 생겼는데

그것마저 서로 다른 계정으로 커밋 할 일이 생긴것..!

그 이유는 바로 회사 프로젝트는 Gitlab을 사용중이고 개인 공부는 Github을 사용중인터라..

어쩔수 없이 프로젝트 단위로 ID, PW, Password를 설정하는 방법을 찾아씁니다.

 

1. Global Git Config 확인

명령어

git config --list --global

 

출력

core.excludesfile=/Users/incross0915/.gitignore_global
core.editor=/usr/bin/vim
core.quotepath=false
difftool.sourcetree.cmd=opendiff "$LOCAL" "$REMOTE"
difftool.sourcetree.path=
mergetool.sourcetree.cmd=/private/var/folders/9y/59r2rgx15mq52vy54qxbcjsr0000gn/T/AppTranslocation/9D9B8CD7-EB49-4A27-A924-24F9C7308133/d/Sourcetree.app/Contents/Resources/opendiff-w.sh "$LOCAL" "$REMOTE" -ancestor "$BASE" -merge "$MERGED"
mergetool.sourcetree.trustexitcode=true
commit.template=/Users/incross0915/.stCommitMsg
user.name=신승욱
user.email=ukseung.dev@incross.com
user.password={secret}
credential.helper=osxkeychain

password는 자체 모자이크입니다 ㅋ

이 상태로 커밋하게되면 global name, email로 Author로 커밋이 됨

 

2. Local Git Config 확인

 

명령어

git config --list --local

 

출력

core.bare=false
core.repositoryformatversion=0
core.filemode=true
core.ignorecase=true
core.precomposeunicode=true
core.logallrefupdates=true

 

user.name, user.email, user.password가 없는 것을 확인

이렇게 되면 Global의 user.name, user.email, user.password로 commit이 됨!

 

3. Local Git Config 변경

두가지 방법이 있으3

두개는 취향 차이고 결과는 같으므로 참고 바람!

Local 설정의 모든 명령어는 프로젝트 .git의 경로에서 진행합니다!

 

3-1. 명령어로 .git/config 변경

명령어

git config --local user.name "Your Name"
git config --local user.email "your.email@example.com"
git config --local user.password "Your password"

 

core.bare=false
core.repositoryformatversion=0
core.filemode=true
core.ignorecase=true
core.precomposeunicode=true
core.logallrefupdates=true
user.name=Your Name
user.email=your.email@example.com
user.password=Your password

이후 Local config 명령어로 확인해보면 name, email, password가 들어간 것을 확인 할 수있음.

참고로 password는 github 로그인 password가 아닌 ssh Key 및 GH Token임

이후에 커밋하면 Author가 변경되어있음.

 

 

3-2. nano 혹은 vi로 .git/config 변경

 

명령어

vi .git/config
nano .git/config

 

나는 vi가 더 편하기 때문에 vi로 진행하게씀다 결과는 같습니다!

쥔장 맘대로

 

before

 

after

 

4. 커밋 결과 확인

기존 커밋은 revert --soft로 돌려서 다시 커밋해보면 해당 결과가 나옴

이렇게 하면 특정 프로젝트마다 다른 설정으로 .git/config를 설정할 수 있돠

 

자주 쓰이는 명령어들 모음

// 🔹 1. 프로젝트(Local) 설정 확인
git config --list --local

// 🔹 2. 사용자 정보(Local 설정)
git config --local user.name "Your Name"
git config --local user.email "your.email@example.com"

// 🔹 3. 기본 브랜치 설정
git config --local init.defaultBranch main

// 🔹 4. 원격 저장소 URL 변경
git config --local remote.origin.url https://github.com/your-repo.git

// 🔹 5. 줄바꿈 자동 변환 설정
git config --local core.autocrlf input  # macOS/Linux
git config --local core.autocrlf true   # Windows

// 🔹 6. Git에서 캐시된 파일 무시 설정
git config --local core.ignorecase false

// 🔹 7. 특정 파일 권한 변경 감지
git config --local core.fileMode false

// 🔹 8. 프로젝트 설정 파일 직접 수정
nano .git/config
//혹은
vi .git/config

// 🔹 9. 특정 Git 설정 삭제
git config --local --unset user.email
git config --local --unset user.name


// 🔹 10. 프로젝트(Local) 설정 전체 삭제
rm -rf .git

 

 

결론

자주 쓰게될 방식인지는 모르겠다. 보통 한 Local당 한개의 아이디를 사용하니

그치만 까먹을 수 도있으니 기록하자 '적자생존'..

예..? ㅋㅋ

728x90
반응형

'Git' 카테고리의 다른 글

error: GH013: Repository rule violations found for ~HEAD  (3) 2024.09.27
[Git] git status, 한글 깨짐  (0) 2024.09.09
욱승