LoginSignup
0
0

More than 1 year has passed since last update.

【Dokcer】gitを使用する【Remote-Containers】

Posted at

はじめに

Remote-Containersでgitを使用する方法について記載します。
設定を行わないと以下のようなエラーが発生します。

ターミナル
$ git clone git@github.com:sample/example.git .
Cloning into '.'...
git@github.com: Permission denied (publickey).
fatal: Could not read from remote repository.

Please make sure you have the correct access rights
and the repository exists.

OSによって手順が異なりますのでMacの設定方法について記載します。

gitを使用する方法

秘密鍵を作成してGitHubに公開鍵を設定します。
次に以下のコマンドをローカルで実行し、ssh-agentにローカルSSHキーを追加します。

ターミナル
$ ssh-add ~/.ssh/id_rsa
Identity added: /Users/user_name/.ssh/id_rsa (user_name@MacBook-Pro.local)

上記のファイル名については異なる可能性があります。
追加されたか以下のコマンドで確認します。

ターミナル
$ ssh-add -l

以上でRemote-Containersでもgitを使用できるようになります。
PCを再起動した場合には上記の手順を再度ローカルSSHキーを追加する必要があります。

また、.gitconfigも自動的にコピーされます。
以下のようなエラーが発生した場合には.gitconfigにエディタの設定を追加してください。

error: unable to start editor 'editor'

vscodeに設定する場合には以下のコマンドで設定することができます。

ターミナル
$ git config --global core.editor "code --wait"
0
0
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
0
0