【git入門】ステージングについて
こんにちは!
間が空きましたが、今回はgitコマンドをまとめてみました。
・リモートリポジトリを作る
・変更をpush
※ステージングについて
・リモートリポジトリを作る(gitthubのとおり)
$echo "# testrepojitory" >> README.md //reeadmeの作成
$ git init //リポジトリの新規作成コマンド(初期化)
$git add README.md //インデックスに追加
$git commit -m "first commit" //最初のコミット
$git remote add origin 【追加したいリポジトリ(今回はtestrepojitory.git)】
//新しいリモートの追加
//$git remote add origin https://github.com/【gitのアカウント名】/testrepojitory.git
$git push -u origin master // リモートのoriginにpush
※新しく追加したリモートリポジトリの確認
$git remote -v
origin https://github.com/wa-www/testrepojitory.git (fetch)
origin https://github.com/wa-www/testrepojitory.git (push)
・変更をpush
$ git add . //カレントディレクトリの差分をすべてインデックスに入れる
$git status
$ git commit -m "新規作成" //最初のコミット
$git push origin 【ブランチ名】
※ステージングについて
・ワーキングディレクトリ:現在作業しているディレクトリ
↓git add
・インデックス(ステージングエリア):コミット準備期間中の待ち状態のファイルたち・ここにいないファイルはpushできない
↓git push
・リモートリポジトリに反映
参考にさせていただきました
git add ってなんのためにやるの? Gitの「ステージング」をイラストで解説します! – KRAY Inc.