LoginSignup
0
0

More than 1 year has passed since last update.

既存のディレクトリをgit管理にしてリモートリポジトリと紐づけ

Posted at

既に作成済みのプロジェクトをgit管理したかったので、備忘録。

対象のディレクトリに移動後

git init

このとき、下記のエラーが出たため、

xcrun: error: invalid active developer path (/Library/Developer/CommandLineTools), missing xcrun at: /Library/Developer/CommandLineTools/usr/bin/xcrun

コマンドラインツールをインストールした。

ターミナルを開いて下記をrun:

xcode-select --install

Xcodeは必要じゃないよ、ここでは130MBのコマンドラインツールのみのインストールだよ。
もしこれだけだとワークしなければ、下記を動かしてみてね。とのこと。

This will download and install the Command Line Tools package and fix the problem.
You do not need Xcode, you can install only the Command Line Tools here, it is about 130Mb.
If the above alone doesn't do it, then also run:

sudo xcode-select --reset

ref. Stack Exchange | Why am I getting an “invalid active developer path” when attempting to use Git after upgrading to macOS Monterey?

無事git initできました。
ファインダー上からも隠しファイルとして.gitが確認できます。

続きましてリモートリポジトリを設定。

・ SSH版(GitHub)

$ git remote add origin git@github.com:ユーザ名/リポジトリ名.git

・ SSH版(HTTPS)

$ git remote add origin https://github.com/ユーザ名/リポジトリ名.git

ディレクトリ内全てのファイルをgit管理するためには、git addによるステージングが必要。

git add *
git commit -m 'first commit'

最後にリモートリポジトリへgit pushします。

git push origin master
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