やってみる

アウトプットすべく己を導くためのブログ。その試行錯誤すらたれ流す。

GitHubにアップロードしてみた

GitHubにアップロードしてみました。

https://github.com/ytyaru/ColorEditor20160609
https://github.com/ytyaru/ColorEditor20160610
https://github.com/ytyaru/ColorEditor20160614

流れ

環境はWindowsXPです。

とてつもなく大変でした。

  1. Git for Windows を用意する
    1. Git for Windowsをダウンロードする
    2. Git for Windowsをインストールする
  2. GitHubに登録する
    1. GitHubのアカウントを作成する
    2. GitHubにログインする
  3. SSH環境を用意する
    1. SSH鍵を作成する
      1. 以下のパスへ移動する
        C:\Documents and Settings\Administrator\.ssh
      2. SSH鍵を作成する
        GitBash > ssh-keygen -t rsa -C "your_email@youremail.com" -f [fileName]
        • configファイル
        • 秘密鍵ファイル([fileName])
        • 公開鍵ファイル([fileName].pub)
    2. GitHubSSH公開鍵を登録する
      https://github.com/settings/ssh
    3. C:\Documents and Settings\Administrator\.ssh/configファイルに以下を追記する
      Host github.com.ytyaru
      User git
      Port 22
      HostName github.com
      IdentityFile ~/.ssh/[fileName]
      TCPKeepAlive yes
      IdentitiesOnly yes
    4. 接続テストする GitBash > ssh -T github.com.ytyaru
  4. GitHubリポジトリを作成する
  5. アップロードするソースコードを作成しておく
  6. 以下のバッチを実行する

:: GitHubアカウント
SET USER_NAME=ytyaru
SET USER_MAIL=xxxxx@yyyyy
:: "C:\Documents and Settings\Administrator\.ssh\config"ファイルの対象"HOST"
SET SSH_HOST=github.com.ytyaru
:: GitHubのリポジトリ名(アップロード先リポジトリ名)
SET REPOSITORY_NAME=ColorEditor20160610

:: ローカルリポジトリに.gitファイル一式を作成(リビジョン管理の開始)
git init

:: アカウント切替
git config --local user.name "%USER_NAME%"
git config --local user.email "%USER_MAIL%"

:: ローカルリポジトリにソースコードをステージングしコミットする
git add .
git commit -m "initial commit"

:: .git/configの設定追記コマンド。1回だけ実行すればいい。
:: 「fatal: remote origin already exists.」というエラーが表示されたらコメントアウトする。
git remote add origin git@%SSH_HOST%:%USER_NAME%/%REPOSITORY_NAME%.git

:: ローカルリポジトリからリモートリポジトリへ修正を反映させる
git push origin master

参考

http://dev.classmethod.jp/tool/github-ssh-sub-account-setting/
http://www.slideshare.net/nullpopopo/github-12293342
http://dackdive.hateblo.jp/entry/2015/10/12/210547