[JAVA_Back-End]

[Github] Make sure you configure your 'user.name' and 'user.email' in git 본문

Utilities/Github

[Github] Make sure you configure your 'user.name' and 'user.email' in git

너굴위 2024. 3. 25. 17:29
728x90
반응형

깃허브 에러메세지

 

vscode를 통해 Repository를 Clone하고, Commit 명령어를 실행시킬 때 발생한 에러 코드

Make sure you configure your 'user.name' and 'user.email' in git

 

Github에서 초기 설정을 해주지 않아 발생한 문제이다.


Git Commit을 수행할 때, 고려해야 할 점은

  1. 코드를 처음 작성한 사람(Author)
  2. 마지막으로 커밋을 수행한 사람(Committer)

의 정보가 등록되어 있어야 한다.

 

만약 세팅이 아무것도 되어있지 않은 상태에서 Repository를 Clone하고 커밋을 수행하면, 설정된 정보를 확인할 수 없기 때문에 해당 에러메세지가 나오게 되는 것이다.

 

해결 방법은 아래와 같다.

 


Global 옵션으로 유저 이름, 이메일 설정하기

! git bash를 실행시켜 설정 !

 

username

$ git config --global user.name "{유저 이름}"

 

useremail

$ git config --global user.email "{깃허브 이메일}"

 

--global 옵션을 통해 이름과 이메일을 설정하면 해당 설정은 컴퓨터의 모든 Repository에 설정된다.

= 어느 Repository에서든 설정된 사용자 이름과 이메일로 커밋이 된다.

+) Repository 별 이름과 이메일 설정이 따로 필요하지 않는 한 global하게 설정하면 된다.


Local 옵션으로 유저 이름, 이메일 설정하기

! Commend에서 현재 경로를 Git Repository경로로 옮긴 후에 명령어를 수행해야 한다 !

username

$ git config user.name "{사용자 이름}"

 

useremail

$ git config user.email "{사용자 깃허브 이메일}"

 

--global 옵션을 빼면 local로 세팅이 된다.

= Repository 개별적으로 사용자 이름과 이메일을 설정할 수 있다.

+) 로컬로 설정한 옵션들은 global 설정보다 우선순위가 높으며, Commit시에 global 설정을 무시하고 local하게 설정된 값을 따른다.


현재 설정된 username, useremail 확인

Local

$ git config user.name
$ git config user.email

 

Global

$ git config --global user.name
$ git config --global user.email

 

Config 정보 확인하기

$ git config --list

local 유저정보를 설정하는 경우

상황: 원격 서버를 이용한 협업

전제: --global 옵션으로 서버 상에서 설정해 놓은 유저 정보가 있을 때

원인: local 유저정보를 설정하지 않으면 

결과: global유저의 정보로 해당 커밋이 올라가게 된다.

728x90
반응형

'Utilities > Github' 카테고리의 다른 글

[Github] error: src refspec main does not match any  (0) 2024.03.25
[Github] 명령어로 코드 관리하기  (0) 2024.03.25