0
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

プログラミング練習記録 2日目:GitHub アカウント作成・初期リポジトリ作成

Posted at

1.本日の作業内容

 GitHub アカウント作成・初期リポジトリ作成

2.作業目的

 ・GitHubのアカウントを使ってコードをクラウドに保存できるようにする
 ・ローカルで作ったコードをGitHubと連携できる準備をする

3.前提

 ・Gitがインストール済みであること
 ・メールアドレスが使えること(GitHubに登録が必要)

4.作業手順

1.GitHubアカウントを作成

  • 下記URLにアクセス
     https://github.com/
  • Sign upから必要な情報を入力してアカウント作成
     ※無料プランで問題なし(Privateリポジトリが作成可能であるため)

2.GitHub上でリポジトリを作成

  • ログイン後、右上の「+」から「New repository」を選択
  • 設定項目:
    • Repository name:例)my-learning-project
    • Description:任意
    • Public/Private:どちらでもOK(Privateなら非公開)
    • Initialize this repository with:
      • README:チェックする
      • .gitignore:Node/C# あとから追加も可能
  • Create repositoryで作成完了

3.GitとGitHubの連携

SSHキーを作成してGitHubと接続。
※なぜSSHキーの登録が必要なのか。

  • 毎回ログインしなくて済む
    • SSH接続なら、1度設定すればコマンド一つでpush/pullが可能
  • セキュアで安全
    • 公開鍵暗号方式で通信することで、パスワードを第三者に知られる心配が少。

↓↓設定方法

  • Git Bashでssh-keygen -t ed25519 -C "メールアドレス"を実行。
    • 保存場所:そのままEnterでOK
    • 「パスフレーズ(暗証番号)」:空欄でもOK。セキュリティ的にあったほうが〇。
  • 完了後以下鍵ファイルができる。
    • 公開鍵(GitHubに登録)
    • 秘密鍵(自分のPCで使用)
  • 公開鍵をGitHubに登録
    • Git Bushでcat ~/.ssh/id_ed25519.pubを実装。
    • 出てきた文字列をすべてコピーして、GitHubに貼り付け。
      • GitHub登録手順:
        • 右上のアイコン→settings(設定)
        • 左メニュー→SSH and GPG keys
        • 「New SSH key」
        • タイトルをつけて貼り付け
  • 接続確認
    • Git Bushでssh -T git@github.comを実行。
    • 「Hi username! You've successfully authenticated, but GitHub does not provide shell access.」と表示されれば成功!

4.ローカルからリポジトリを複製

  • Git Bushで下記を実行。
    cd ~/your-working-folder
    git clone git@github.com:あなたのユーザー名/my-learning-repo.git
    cd my-learning-repo
    

5.ファイル追加と初回コミット

  • Git Bushで下記を実行。
    echo "# My Learning Repo" > README.md
    git add .
    git commit -m "Initial commit"
    git push
    

5.完了チェックポイント

  • GitHubアカウントが作成できた
  • GitHubに新しいリポジトリがある
  • PC上に git clone したローカルリポジトリがある
  • git push でコードをアップできた
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

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?