1
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

ローカルの既存ソースコードを後からGitHubに追加する方法

Posted at

大まかな手順

  1. GitHubにて新規リポジトリ(リモートリポジトリ)を作成
  2. 既存ソースコードをGitリポジトリとして初期化
  3. 既存ソースコード(ローカルリポジトリ)をリモートリポジトリにプッシュ

実際の手順

1. GitHubにて新規リポジトリ(リモートリポジトリ)を作成

  1. GitHubに移動
  2. Newボタンを押下し、新規リポジトリを作成
    001.png

2. 既存ソースコードをGitリポジトリとして初期化

  1. 既存ソースコードのあるディレクトリまで移動
terminal
cd [既存ソースコードのあるディレクトリ]

2. 既存ソースコードをGitリポジトリとして初期化

terminal
git init

3. 既存ソースコード(ローカルリポジトリ)をリモートリポジトリにプッシュ

  1. 既存ソースコードをステージングに追加
terminal
git add .

2. ステージングに追加した内容をコミット

terminal
git commit -m "ローカルの既存ソースコードを後からGitHubに追加"

3. GitHubにてリポジトリのURLをコピー
002.png
4. コピーしたリポジトリをリモートリポジトリとして追加

terminal
git remote add origin <リポジトリのURL>

5. ローカルリポジトリをリモートリポジトリにプッシュ

terminal
git push -u origin main
1
1
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
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?