前提
最近githubのサブアカウントを作ったのですがその時あたりからメインアカウントでpushできません。
実現したいこと
githubにメインアカウントでファイルをアップロードしたいです。
発生している問題・エラーメッセージ
ファイル名 % git push -u origin main remote: Permission to メインアカウント名/ファイル名.git denied to サブアカウント名. fatal: unable to access 'https://github.com/メインアカウント名/ファイル名.git/': The requested URL returned error: 403
というエラーが起きます。
問題はdenied toサブアカウントとなる点でメインアカウントとしてアクセスしたいのにサブアカウントでアクセスされてるっぽいです。
該当のソースコード
command
1ファイル名 % cat .git/config 2[core] 3 repositoryformatversion = 0 4 filemode = true 5 bare = false 6 logallrefupdates = true 7 ignorecase = true 8 precomposeunicode = true 9[remote "origin"] 10 url = https://github.com/メインアカウント名/ogm_test.git 11 fetch = +refs/heads/*:refs/remotes/origin/*
試したこと
サブアカを作ったのでconfigにアカウト情報を追加しました。
アクセス自体はできるっぽいです。
config
1#メインアカウント 2Host github-メインアカウント名 github-メインアカウント名.com 3 HostName github.com 4 IdentityFile ~/.ssh/id_メインアカウント名_rsa 5 User git 6 Port 22 7 TCPKeepAlive yes 8 IdentitiesOnly yes 9 10#サブアカウント 11Host github-サブアカウント名 github-サブアカウント名.com 12 HostName github.com 13 IdentityFile ~/.ssh/id_サブアカウント名_rsa #サブアカウントの鍵のファイル 14 User git 15 Port 22 16 TCPKeepAlive yes 17 IdentitiesOnly yes
command
1.ssh % ssh -T git@github-メインアカウント名.com 2Hi メインアカウント名! You've successfully authenticated, but GitHub does not provide shell access.
command
1.ssh % git config -l | grep user. 2user.name=メインアカウント名 3user.email=メインアカウントメールアドレス
configはメインアカウントになってます。
どうすればメインアカウントに切り替えることができますか?
回答1件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。
2022/09/15 12:19