1
3

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 1 year has passed since last update.

【GitHub】VScodeからGitHubへソースをプッシュする

Posted at

はじめに

GitHubに新規リポジトリを作るところから、VSCodeのソースをプッシュするところまで、久々すぎてやり方を忘れていたため、備忘録として書きます。

VSCode側の準備

git initで作業ディレクトリ配下に.gitディレクトリを作成する。
ここを忘れていたため、この後のgit remoteでエラーが出た。

VSCodeのターミナルを開く
作業ディレクトリまで移動して以下のコマンド実行

$ git init
Initialized empty Git repository in 作業ディレクトリ/.git/

このように.gitディレクトリが作成されればOK。
image.png

続いてソースをコミットする。

$ git add .
$ git commit -m "初期作成"

GitHubで新規リポジトリ作成

サイトにアクセスして、新規リポジトリを作成する。

Repository name⇒リポジトリの名前
Public or Private ⇒リポジトリを公開するか非公開にするか
Add a READE file⇒後からでも設定できるので、今回はチェックボックスはOFF

image.png

GitHubとVSCodeの連携

リポジトリのHTTPSをコピー

image.png

次にリポジトリをclone。ソースのプッシュを行う
VSCodeのターミナルを開く

$ git remote add origin [リモートリポジトリのHTTPSのcopy]
$ git push origin master 

ここで.gitディレクトリが無いと以下のエラーが発生するので、git initをする

fatal: not a git repository (or any parent up to mount point /mnt)        
Stopping at filesystem boundary (GIT_DISCOVERY_ACROSS_FILESYSTEM not set).

終わりに

GitHubの草を沢山生やすのが今の目標です。
沢山アウトプットしよう

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

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?