IT story

이메일이 없거나 이메일 만있는 다른 사용자로 GIT 커밋

hot-time 2020. 8. 3. 17:36
반응형

이메일이 없거나 이메일 만있는 다른 사용자로 GIT 커밋


다른 사용자로 일부 변경 사항을 커밋하려고하는데 유효한 전자 메일 주소가 없습니다. 다음 명령이 작동하지 않습니다.

git commit --author="john doe" -m "some fix"
fatal: No existing author found with 'john doe'

이메일 주소로만 커밋하려고 할 때도 같은 문제가 있습니다

git commit --author="john@doe.com" -m "some fix"
fatal: No existing author found with 'john@doe.com'

commit 명령에 대한 GIT 매뉴얼 페이지에서 사용할 수 있다고 말합니다.

standard A U Thor <author@example.com> format

--author 옵션의 경우

이 형식은 어디에 정의되어 있습니까? A와 U는 무엇을 의미합니까? 사용자 이름이나 이메일만으로 다른 사용자를 어떻게 커밋합니까?


년에 암시 같이 최소한의 필요한 저자의 형식은, 이 SO 답변 입니다

Name <email>

귀하의 경우, 이것은 당신이 쓰고 싶다는 것을 의미합니다

git commit --author="Name <email>" -m "whatever"

Willem D' Haeseleer의 의견에 따르면, 이메일 주소가 없으면 다음을 사용할 수 있습니다 <>.

git commit --author="Name <>" -m "whatever"

링크 된 git commit매뉴얼 페이지 에 기록 된대로 , 그보다 적은 것을 제공하면 이전 커밋을 검색하는 검색 토큰으로 사용되어 해당 작성자의 다른 커밋을 찾습니다.


구체적인 형식은 다음과 같습니다.

git commit --author="John Doe <john@doe.com>" -m "Impersonation is evil." 

그만큼

표준 AU Thor <author@example.com> 형식

다음과 같이 정의 된 것 같습니다 : (내가 아는 한, 보증은 없습니다)

AU Thor = 필수 사용자 이름

  • 문자의 분리는 아마 공간, 또한 이니셜을 닮은 될 수있는 허가되는 것을 나타냅니다.
  • 사용자 이름 뒤에 1 개의 공백이 와야합니다. 추가 공백은 잘립니다.

<author@example.com> = 선택적 이메일 주소

  • 항상 <> 기호 사이에 있어야합니다.
  • 이메일 주소 형식이 확인되지 않았으므로 원하는대로 입력 할 수 있습니다
  • 선택적으로 <>를 사용하여이를 명시 적으로 생략 할 수 있습니다.

이 정확한 구문을 사용하지 않으면 git은 기존 커밋을 검색하고 제공된 문자열이 포함 된 첫 번째 커밋을 사용합니다.

예 :

  1. 사용자 이름 만

    이메일 주소를 명시 적으로 생략하십시오.

    git commit --author="John Doe <>" -m "Impersonation is evil."
    
  2. 이메일 만

    기술적으로는 불가능합니다. 그러나 이메일 주소를 사용자 이름으로 입력하고 이메일 주소를 명시 적으로 생략 할 수 있습니다. 이것은 매우 유용한 것처럼 보이지 않습니다. 이메일 주소에서 사용자 이름을 추출한 다음 사용자 이름으로 사용하는 것이 더 합리적이라고 생각합니다. 그러나 당신이해야한다면 :

    git commit --author="john@doe.com <>" -m "Impersonation is evil." 
    

나는 저장소를 수은에서 git로 변환하려고 할 때 이것에 부딪쳤다. msysgit 1.7.10에서 명령을 테스트했습니다.


그냥 보충 :

git commit --author = "john@doe.com"-m "명의 도용은 사악합니다."

경우에 따라 커밋이 계속 실패하고 다음 메시지가 표시됩니다.

*** 당신이 누구인지 알려주세요.

운영

git config --global user.email "you@example.com"git config --global user.name "당신의 이름"

계정의 기본 ID를 설정합니다. 이 저장소에서만 ID를 설정하려면 --global을 생략하십시오.

치명적 : 이메일 주소를 자동 감지 할 수 없습니다 (xxxx가 표시됨)

"git config"를 실행 한 다음 "git commit"을 실행하십시오.


체재

A U Thor <author@example.com>

단순히 지정해야 함을 의미합니다.

FirstName MiddleName LastName <email@example.com>

중간 이름과 성은 선택 사항처럼 보입니다 (이메일의 형식이 엄격하지 않은 부분 일 수 있음). 예를 들어 다음을 시도하십시오.

git commit --author="John <john@doe.com>" -m "some fix"

문서에서 말한 것처럼 :

  --author=<author>
       Override the commit author. Specify an explicit author using the standard 
       A U Thor <author@example.com> format. Otherwise <author> is assumed to 
       be a pattern and is used to search for an existing commit by that author 
       (i.e. rev-list --all -i --author=<author>); the commit author is then copied 
       from the first such commit found.

이 형식을 사용하지 않으면 git은 제공된 문자열을 패턴으로 취급하고 다른 커밋의 저자들 사이에서 일치하는 이름을 찾으려고 시도합니다.


Open Git Bash.

Set a Git username:

$ git config --global user.name "name family" Confirm that you have set the Git username correctly:

$ git config --global user.name

name family

Set a Git email:

$ git config --global user.email email@foo.com Confirm that you have set the Git email correctly:

$ git config --global user.email

email@foo.com


Run these two commands from the terminal to set User email and Name

 git config --global user.email "you@example.com" 

 git config --global user.name "your name" 

If you are committing to Github you don't need a real email you can use <username>@users.noreply.github.com

Regardless of using Github or not, you probably first want change your committer details (on windows use SET GIT_...)

GIT_COMMITTER_NAME='username' 
GIT_COMMITTER_EMAIL='username@users.noreply.github.com'

Then set the author

git commit --author="username <username@users.noreply.github.com>"

https://help.github.com/articles/keeping-your-email-address-private

참고URL : https://stackoverflow.com/questions/11579311/git-commit-as-different-user-without-email-or-only-email

반응형