github.comのアカウント変更した時のケア事項

概要

github.comのアカウントを変更したくなりましたので、変更方法と変更した後のケア事項をまとめてました。

変更方法

  1. 画面右上のプルダウンメニューから「Setting」を選択 f:id:lgx:20210925140502p:plain:w350
  2. Account settingメニューから「Acount」を選択 f:id:lgx:20210925140932p:plain:w350
  3. 「Change username」ボタンを押下 f:id:lgx:20210925141141p:plain:w400
  4. 警告画面が表示されるが、I understand ...ボタンを押下 f:id:lgx:20210925141308p:plain:w400
  5. 次にはアカウント名を変更する画面で変更できる(使われているものはNG) f:id:lgx:20210925141420p:plain:w400

変更後のケア事項

git config user.nameの設定

  1. 現在の設定内容をみず確認する
$ git config --global user.name
  1. 変更後のアカウント名を設定
$ git config --global user.name <new username>
  1. 変更後他の設定も含めて確認する
$ git config --global -l

以前git cloneしたローカルのリポジトリへのケア

数分だけ、以下の操作を実施。

$ cd <ローカルのリポジトリ>
$ git remote -v 
# 変更前の状態
# 変更前
origin  git@github.com:<old_name>/<repo_name>.git (fetch)
origin  git@github.com:<old_name>/<repo_name>.git (push)

# 新しいusernameに変更
$ git remote set-url origin git@github.com:<new_name>/<repo_name>.git
$ git remote -v

# 確認(以下になっていればOK)
origin  git@github.com:<new_name>/<repo_name>.git (fetch)
origin  git@github.com:<new_name>/<repo_name>.git (push)

これで普通に$ git clone$ git pushなど新しいアカウントに対して操作できるはず。

参考資料(THX!)