1
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

ローカルプロジェクトを新規リポジトリに初回pushする手順

Last updated at Posted at 2025-08-04

はじめに

ローカルにあるプロジェクトフォルダの中身を、GitHub上の新しく作成したリポジトリにpushする手順を毎回忘れてしまうので、備忘録として残しておきます。

以下の手順でコマンドを実行

  1. cdコマンドで対象ディレクトリに移動
  2. git init
    2.1. 必要に応じて .gitignore ファイルを作成・編集(例:node_modules/ などを除外)
  3. git branch -m main
  4. git add .
  5. git commit -m "コメントを記述"
  6. git remote add origin https://github.com/YOUR_USERNAME/REPOSITORY_NAME.git
  7. git push -u origin main

GitHubでリポジトリ作成時は、Add READMEAdd licenseを追加せず、空の状態で作成するとスムーズです。

リポジトリ名だけ設定するイメージです。

二回目以降のpush手順

  1. cdコマンドで対象ディレクトリに移動
  2. git add .
  3. git commit -m "更新内容などコメントを記述"
  4. git push
  • 2回目以降はgit initremote addなどは不要です
  • 新規ファイル作成や大きな変更があるときは、.gitignoreの見直しも推奨

おわりに

今更、初歩的な内容になってしまいましたが、慣れるまでは何度もカンニングしようと思います。

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

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?