LoginSignup
1
0

More than 3 years have passed since last update.

SourceTreeを使ってGithubにコードをあげていく

Posted at

状況整理

Laravelで作成したファイルをターミナルでgit管理していると

Herokuにgit pushする必要があったり
Githubにgit pushする必要があったり
ターミナルで一元管理するのはリスクが出てきたため、

この際、GithubにあげるデータはSourceTreeでGit管理して
Herokuなどのクラウドサーバーに上げるときはターミナルコマンドを使用することにした。

①Githubで新規リポジトリを作成する

スクリーンショット 2019-09-15 18.56.26.png

②該当ファイルからターミナルを開く(※エディタのターミナルでも〇)

スクリーンショット 2019-09-15 18.59.38.png

③ターミナルを開いたらコードを貼り付け

…or create a new repository on the command lineの部分をターミナルに貼り付けて実行
スクリーンショット 2019-09-15 18.58.11.png

echo "# -" >> README.md
git init
git add README.md
git commit -m "first commit"
git remote add origin https://github.com/〇〇/〇〇.git
git push -u origin master

これでgit commitする準備ができました。

次にSourceTreeを開きます。

④既存のローカルリポジトリを追加

スクリーンショット 2019-09-15 19.06.20.png

該当ファイルを選択したら管理画面が開きます。
スクリーンショット 2019-09-15 19.07.52.png

⑤右上の設定→リモートからパスが、https://〜から始まるgitかチェックする

スクリーンショット 2019-09-15 19.08.52.png

git@github〜から始まるgitだとエラーが出るので注意です。

これでSourceTreeを使ってgit pushできるようになりました。

1
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
1
0