development

터미널에서 내 Git 사용자 이름을 변경하는 방법은 무엇입니까?

big-blog 2020. 9. 17. 08:23
반응형

터미널에서 내 Git 사용자 이름을 변경하는 방법은 무엇입니까?


터미널에서 git을 밀고 당기고 github.com에서 사용자 이름을 변경했습니다. 일부 변경 사항을 푸시하러 갔는데 여전히 이전 사용자 이름을 인식하고 있기 때문에 푸시 할 수 없습니다. 터미널의 git에서 사용자 이름을 변경 / 업데이트하려면 어떻게해야합니까?


github가 사용자 이름을 입력하므로 원격 URL을 업데이트해야 할 수 있습니다. 다음을 입력하여 원래 URL을 볼 수 있습니다.

git config --get remote.origin.url

또는 Github의 저장소 페이지로 이동하여 새 URL을 얻으십시오. 그런 다음

git remote set-url origin https://{new url with username replaced}

새 사용자 이름으로 URL을 업데이트합니다.


  1. 터미널에서 변경하려는 저장소로 이동합니다.
  2. git config --list로컬 저장소에서 현재 사용자 이름 및 이메일을 확인하려면 실행 하십시오.
  3. 원하는대로 사용자 이름 및 이메일을 변경합니다. 전역 변경 또는 로컬 리포지토리에만 적용 :
    git config [--global] user.name "Full Name"
    git config [--global] user.email "email@address.com"

    리포지토리별로 .git/config수동으로 편집 할 수도 있습니다 .
  4. 끝난!

수행하는 2 단계 당신이 볼 경우 credential.helper=manager컴퓨터 (승리 또는 Mac)의 자격 증명 관리자를 열어야 및 업데이트 자격 증명이

다음은 Windows에서 어떻게 보이는지입니다. 여기에 이미지 설명 입력

문제 해결? 더 알아보기


  1. 편집 : 이름과 이메일을 변경하는 것 외에도 자격 증명을 변경해야 할 수도 있습니다.

    • 하나의 저장소에 대해서만 로컬로 변경하려면 저장소 내에서 터미널에 입력하십시오.

      git config credential.username "new_username"

    • 글로벌 사용을 변경하려면

      git config credential.username --global "new_username"

    (EDIT EXPLAINED: If you don't change also the user.email and user.name, you will be able to push your changes, but they will be registered in git under the previous user)

  2. Next time you push, you will be asked to enter your password

    Password for 'https://<new_username>@github.com':


To set your account's default identity globally run below commands

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

To set the identity only in current repository , remove --global and run below commands in your Project/Repo root directory

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

**Example:** 
email -> organization email Id
name  -> mostly employee Id or FirstName, LastName 

**Note: ** you can check these values in your GitHub profile or Bitbucket profile


Please update new user repository URL

 git remote set-url origin https://username@bitbucket.org/repository.git

I tried using below commands, it's not working:

git config user.email "email@example.com"
git config user.name  "user"

OR

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

From your terminal do:

git config credential.username "prefered username"

OR

git config --global user.name "Firstname Lastname"

I recommend you to do this by simply go to your .git folder, then open config file. In the file paste your user info:

[user]
    name = Your-Name
    email = Your-email

This should be it.


There is a easy solution for that problem, the solution is removed the certificate the yours Keychain, the previous thing will cause that it asks again to the user and password.

Steps:

  1. Open keychain access

여기에 이미지 설명 입력

  1. Search the certificate gitHub.com.

  2. Remove gitHub.com certificate.

  3. Execute any operation with git in your terminal. this again ask your username and password.


If you have created a new Github account and you want to push commits with your new account instead of your previous account then the .gitconfig must be updated, otherwise you will push with the already owned Github account to the new account.

이 문제를 해결하려면 홈 디렉토리로 이동하여 편집기로 .gitconfig를 열어야합니다. 편집기는 vim, notepad ++ 또는 메모장 일 수 있습니다.

.gitconfig가 열리면 푸시 할 새 Github 계정 사용자 이름으로 "이름"을 수정하면됩니다.

참고 URL : https://stackoverflow.com/questions/22844806/how-to-change-my-git-username-in-terminal

반응형