LoginSignup
4
2

More than 3 years have passed since last update.

ローカルディレクトリをGitHubのリモートリポジトリへ新規Push

Posted at

はじめに

手元の Linux 環境で作成したディレクトリを使って、GitHub の新規 Repository へ Push する手順を備忘録としてメモしています。

ローカル環境

こんな感じで、ローカルにある Python のソースコードを GitHub へ Push したい状態です。

> ls -la
total 4
drwxr-xr-x  3 ec2-user docker   44 Apr  4 17:24 .
drwx------ 13 ec2-user docker  294 Apr  4 12:28 ..
-rw-r--r--  1 ec2-user docker 1509 Apr  4 17:26 selectAurora.py
drwxr-xr-x  3 ec2-user docker   47 Apr  3 18:06 .vscode

まず、git init で初期化します。

git init

VS code を使っているので、.gitignore を作成して、.vscode を無視します。

.vscode/

git status で確認します

> git status
On branch master

No commits yet

Untracked files:
  (use "git add <file>..." to include in what will be committed)
        .gitignore
        selectAurora.py

nothing added to commit but untracked files present (use "git add" to track)

全ファイルを追加

git add -A

git commit を実施

git commit -m "first commit"

GitHub で新規 Repository 作成

画面右上から、Your repository へ移動

image-20210404174216462.png

New を押す

image-20210404174237720.png

Create Repository

image-20210404174419944.png

作成完了。HTTPS の URL をメモっておきます

image-20210404174440448.png

ローカル環境

remote origin として設定

git remote add origin https://github.com/Sugi275/mysql-connection-python-sample.git

Push

git push origin master

Push される

image-20210404174635811.png

参考URL

4
2
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
4
2