Hello, World!!

むずかしいことはかけません

ローカルで作ったプロジェクトをリモート(github)に上げる

githubリポジトリを作った時に手順書いてあるんですけど、簡単にメモします。

例えばローカルでLaravelでプロジェクト作って、それをgitにあげたい場合
まず先にgithubリポジトリ作っとく(リポジトリ名:project)

次に↓

実行コマンド

[~]# composer create-project --prefer-dist laravel/laravel project
[~]# cd project
[~/project]# echo "# project" >> README.md
[~/project]# git init
[~/project]# git add README.md
[~/project]# git commit -m "first commit"
[~/project]# git remote add origin [作ったリポジトリのSSHかHTTP]
[~/project]# git push -u origin master

これで作成したリポジトリにLaravelのプロジェクトがpushされた。

注意

pushした時以下のようなエラーが出たら

ERROR: Permission to User/project.git denied to User.
fatal: Could not read from remote repository.

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

対象のリモートリポジトリへのアクセス権限がないとのことなので、公開鍵を作成してgithubに登録すればOK

[~]# ssh-keygen -t rsa -C [gitアカウントのメールアドレス]
[~]# pbcopy < ~/.ssh/id_rsa.pub

pbcopyでクリップボードにコピーできるので便利