はじめに
Visual Studioのgit機能においてリモートリポジトリを登録後、
pushをしたところエラーが出てしまい、原因が分からず
最初から作り直すことになったので備忘録として残します。
Windowsにおける共有フォルダ(UNCパス上)に
リモートリポジトリを作成して登録し、pushするまでを記事にしました。
実施内容
Visual Studio内リポジトリを作成
ローカルリポジトリを作成
Visua Studioのgit機能を使用してローカルリポジトリのみを作成
コマンドから作成する方法は下記を参考
UNCパス(サーバー上のファイル)にリモートリポジトリを作成
作成したディレクトリに移動
cd Z:\test\eposA
gitフォルダを作成
mkdir git
Gitリポジトリを作成
git init --bare --shared
bareオプションを使用すると、ベアリポジトリを作成します。
ベアリポジトリとは、ワークディレクトリを持たないリポジトリで、bareは「裸の」や「むき出し」を意味します。
git initでDIR環境が設定されていない場合、現在のワークディレクトリに設定されます
sharedオプションを使用することで、すべてのユーザーがこのリポジトリにpushできるよう設定します
Gitコマンドリファレンス(日本語版)は以下です。
リモートリポジトリを登録
ローカルリポジトリの作成ディレクトリに戻る
cd C:\work\projA
リモートリポジトリを登録・プッシュ
git remote add origin Z:\test\reposA\.git
git push origin master
発生した問題
UNCパスをドライブ割り当てしたけど、Z:コマンドで移動できない
Windowsのセキュリティの制約か、UACを設定してローカルグループポリシーエディタを開く
「Windowsの設定」→「ローカルポリシー」→「セキュリティオプション」→「ローカルアカウントの権限」で「UACの動作を変更」
レジストリエディタにて「EnableLinkedConnections」を構成
レジストリエディタを開く。
HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\Systemlに移動
「新規」>「DWORD(32ビット)値」を選択して「EnableLinkedConnections」を作成。
編集ウィンドウで、値のデータフィールドに「1」を設定。
PC再起動。
EnableLinkedConnections=1
git commit時にエラー
error: pathspec 'commit" did not match any file (s) known to git
解決策
コメント部分はダブルクォーテーションで囲みます。
git commit -m "first commit"