2&>1

AWSとかGCPとかGolangとかとか

Github童貞がpushするまでの最低限コマンド

恥ずかしながらGithub童貞でしたが卒業しました。

マイアカウント

github.com

以下コマンドです。

ローカルPCからGithubアカウント準備まで

gitコマンドのインストールしてGithubへアカウント作成します。

詳細はこちらを参考下さい(詳しいから。。)

qiita.com

リポジトリ作成

Githubリポジトリ作成します。 赤丸から

f:id:piyojir0:20190412144609j:plain

リポジトリ名とDescription(リポジトリの説明)だけ入れましょう

f:id:piyojir0:20190412144639j:plain

これでクリエイトすれば完了 以下のような画面が表示されるので閉じずにそのままで。 赤丸部分は下で使う。 f:id:piyojir0:20190412151435j:plain

ローカル側でリポジトリ作ってaddしてcommitしてpushする

適当なフォルダ作成してそこをリポジトリとしてファイルを作ってcommitしてファイル間違えないか確認する

mkdir test-repo
cd test-repo
git init
echo testdayo >> test.txt
git add test.txt
git status
git commit -m "テスト用にファイル作った"

上の赤丸部分をコピーする Githubリポジトリに対してローカルでcommitしたファイルをaddしてpushする

git remote add origin https://github.com/piyoji333/test.git
git push -u origin master

これでGithubの画面上でからも確認できる f:id:piyojir0:20190412151804j:plain

Githubへpushしたファイルを更新する

echo aiueo >> test.txt
git add test.txt
git commit -m "追加分"
git push
git log

以上でGithubへファイルをアップして更新するできたので童貞卒業です。 ありがとうございます。 (ブランチ切ってホニャララとかあるけどまた別で追記する)


コマンド説明

git add hoge

ローカルリポジトリに追加する

git commit -m "hogehoge"

ローカルリポジトリにコメントつけてコミット(正式版にするみたいな)する

git push

リモートリポジトリ(github)へコミットする

git status

現在の状態表示。addしたファイルが表示されるので違うものがaddされてないか確認できる

On branch master
Your branch is up to date with 'origin/master'.

Changes to be committed:
  (use "git reset HEAD <file>..." to unstage)

        modified:   test.txt

git log

commitしたログが表示

commit 24bed244533cb4a0c5efe422da7879a1997468ad (HEAD -> master, origin/master)
Author: hoge <hogehoge@gmail.com>
Date:   Fri Apr 12 15:19:09 2019 +0900

    追加分

commit 2f8773fdb587014570b3eb86819ab0244369c25d
Author: hoge <hogehoge@gmail.com>
Date:   Fri Apr 12 15:15:23 2019 +0900

    テスト用にファイル作った

Githubへコミットする前に気をつけること

・認証情報を含んでないか確認(AWSとかの)

こういうの使うと良い

アクセスキーのコミットを抑止できて安全便利な awslabs/git-secrets - kakakakakku blog

・ソースファイルにミスはないか(typoとかとか)