Program Club

user.email 및 user.name을 설정하지 않고 커밋

proclub 2020. 11. 21. 08:56
반응형

user.email 및 user.name을 설정하지 않고 커밋


이렇게 커밋하려고 해

git commit --author='Paul Draper <my@email.org>' -m 'My commit message'

그러나 나는 얻는다

*** Please tell me who you are.

Run

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

to set your account's default identity.
Omit --global to set the identity only in this repository.

나는 이것을 설정할 수 있지만 나는 공유 상자에 있으며 나중에 설정을 해제해야 할 것입니다.

git config user.name 'Paul Draper'
git config user.email 'my@email.org'
git commit -m 'My commit message'
git config --unset user.name
git config --unset user.email

그것은 하나의 커밋에 대한 많은 줄입니다!

더 짧은 길이 있습니까?


(이것은 환경 변수가있는 긴 버전을 제안한 후에 ​​발생했습니다. git commit은 작성자와 커미터를 모두 설정 --author하고 전자 만 무시합니다.)

모든 git 명령 은 작업 동사 앞에-c 인수 를 사용 하여 임시 구성 데이터를 설정하므로 이것이 완벽한 장소입니다.

git -c user.name='Paul Draper' -c user.email='my@email.org' commit -m '...'

따라서이 경우 하위 명령이 아니라 명령의 -c일부입니다 .gitcommit


.git/config저장소 에서 파일을 편집 하여 다음 별칭을 추가 할 수 있습니다 .

[alias]
  paulcommit = -c user.name='Paul Draper' -c user.email='my@email.org' commit

또는 명령 줄로이를 수행 할 수 있습니다.

git config alias.paulcommit "-c user.name='Paul Draper' -c user.email='my@email.org' commit"

그런 다음 할 수 있습니다.

git paulcommit -m "..."

비고 :

  • 아이디어는 다음처럼 또한 별칭을 추가 jeancommit, georgecommit...이 공유 상자의 다른 사용자.
  • 개인을 편집 .gitconfig하거나 --global별칭을 추가 할 때 명령 줄에 옵션을 추가하여이 별칭을 전역 구성에 추가 할 수 있습니다 .
  • 별칭 paulcommit은 짧은 것이 아니지만 장황하며 일반적으로 git pau+ 만 입력 할 수 있습니다 tab.

참고 URL : https://stackoverflow.com/questions/22058041/commit-without-setting-user-email-and-user-name

반응형