0
1

More than 1 year has passed since last update.

git hubの学習のために初歩的な使い方を載せます。
最近reactの勉強を始め、製作したものをgitにあげてと言われたのですが、存在は知っているけど使い方がいまいちわからない。
まずGithubにログインします。
https://github.com/new
次にrepository nameを入力します。
ソースコードを公開する場合はPublic,しない場合はPrivateにします。
最後に、リポジトリの中にあらかじめREADMEファイルを作成しておく場合は「Initialize this repository with a README」にチェックを入れます。
.gitignoreやlicenseについては後で追加や変更ができるので、Noneを選択します。

項目の入力が終わるとCreate repositoryをクリックすると、リポジトリの完成です。

次はmacのターミナルで行います。

mkdir study //今回はstudyというディレクトリを使用します
cd study    //studyディレクトリに移動します
git init    //Gitリポジトリを新たに作成するコマンド
git status //現在の状態を見ます

結果は以下のようになります

On branch master

No commits yet

Untracked files:
  (use "git add <file>..." to include in what will be committed)
	.gitignore
	README.md
	package-lock.json
	package.json
	public/
	src/

先ほど作成したファイルをローカルリポジトリに追加します。

git add .

addの後ろに.をつけると一括で選択できるらしい。

次に、インデックスに追加されたファイルをコミットします。

git commit -m "add new folder" //""中はメッセージ

これですべてのファイルがコミット済みの状態になりました

On branch master
nothing to commit, working tree clean

次に、リモートリポジトリに反映させるため前に、リモートリポジトリの情報を追加します。
Githubでリポジトリを作成した際に表示されたアドレスをコピーします。

git remote add origin コピーしたアドレス

ローカルリポジトリの変更を、GitHub上にあるリモートリポジトリに反映させるため、以下のコマンドを実行します。

git push origin master

これで、Githubへプッシュしてリモートリポジトリへ反省させることができました。

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