sourcecode

Git: 각 repo에 대해 local user.name 및 user.email을 다르게 설정합니다.

codebag 2023. 6. 22. 21:50
반응형

Git: 각 repo에 대해 local user.name 및 user.email을 다르게 설정합니다.

저는 현재 2개의 프로젝트를 진행하고 있는데, 프로젝트를 진행할 때 로컬 사용자 이름과 이메일을 다른 데이터로 구성할 것으로 예상됩니다.이를 위해 항상 다음과 같이 구성을 업데이트합니다.

git config --local user.email "namelastname@domain.example"

서로 다른 리포지토리이기 때문에 각 리포지토리에 대해 로컬 전자 메일을 정의할 수 있는 방법이 있습니까?

아마 앞으로..gitconfig?

하나의 repo에 대해서만 해당 repo DIR로 이동하여 다음을 수행합니다.

git config user.name "Your Name Here"
git config user.email your@email.example

~/.gitconfig에서 구성된 (글로벌) 기본 전자 메일의 경우:

git config --global user.name "Your Name Here"
git config --global user.email your@email.example

다음을 사용하여 Git 설정을 확인할 수 있습니다.git config user.name && git config user.email

(글로벌과 다른) 새 사용자/구성을 설정한 특정 리포에 있는 경우 로컬 구성이 표시되고 그렇지 않으면 글로벌 구성이 표시됩니다.

터미널에 인쇄하여 확인할 수 있습니다.

  1. 글로벌 사용자:git config --global user.name
  2. 로컬 사용자:git config user.name

...아니면 편집하기만 하면 됩니다..git\config파일을 작성하고 다음 세 줄을 추가합니다.

[user]
    name = YourName
    email = your@email.com

저는 일반적으로 회사 프로젝트와 개인 프로젝트(github)를 위해 이름/이메일을 다르게 보관하는 경향이 있습니다.

사용자/이메일을 지정해야 하는 gitrepo에서 아래 명령 실행

git config user.name <user-name>
git config user.email <user-email>

다음 명령을 사용하여 이를 수행할 수 있습니다.

    git config --local credential.helper ""
    git push origin master

현재 repo에 대한 사용자 이름과 암호를 요청합니다.

제게 확실하게 효과가 있었던 한 가지 비결은 두 가지 모두의 글로벌 구성을 설정하는 것입니다.credential.username로컬 옵션뿐 아니라 옵션도 있습니다.그들은 인증을 위한 비밀번호를 요청할 것입니다.이것은 Mac의 Git Credential Manager에서도 작동합니다.자세한 내용은 https://docs.github.com/en/get-started/getting-started-with-git/caching-your-github-credentials-in-git 을 참조하십시오.따라서 두 개의 다른 GitHub 계정에 대해 적어도 두 개의 다른 암호처럼 캐시할 수 있습니다.

언급URL : https://stackoverflow.com/questions/42167345/git-set-local-user-name-and-user-email-different-for-each-repo

반응형