1
1

More than 1 year has passed since last update.

gitlabへのpush時に"you don't have permission"で失敗した問題の解決

Posted at

概要

  • 内輪用に立てたGitLabサービスでprivate設定のリポジトリにpushする際に失敗した
  • リポジトリが見つからないとのことで、remoteの送り先にアカウント名を含むように修正した。

前提

  • git: git version 2.37.1.windows.1
  • gitリポジトリのProject visibility: Private
  • 使用したプロトコル: https

背景

  • 普段はPublicなリポジトリを操作する事が多かった
  • しかし、家族にプログラム講座をやるためにプライベートな例を含めたリポジトリが欲しくなりPrivateなプロジェクトを作成した
  • clone時は接続後に認証処理をしたが、push時はそもそもパーミッション的に見られないとのエラーが出た
  • remoteのURLをアカウント名を含むように修正し、解決した。

現象

  • 自分で立てたGitLabサービスに作ったPrivateなプロジェクトにpushしようとしたら以下のエラーが出た。
PS Microsoft.PowerShell.Core\FileSystem:<path名>> git push
remote: The project you were looking for could not be found or you don't have permission to view it.
fatal: repository 'https://<GitLabのドメイン>/<プロジェクト所有者名>/<プロジェクト名>.git/' not found

解決方法

  • 元のremoteを消す
git remote remove origin
  • 元のremoteのURLをアカウント名を含むように書き換える
git remote add origin https://<アカウント名>@<GitLabのドメイン>/<プロジェクト所有者名>/<プロジェクト名>.git  

おわりに

  • もしかすると、 `git push'のエラー発生条件は"Project visibility: Private"ではないかもしれないが、絞り込めなかった
  • Enjoy git!

参考サイト

1
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
1