LoginSignup
0
0

More than 1 year has passed since last update.

【github】新規リポジトリ作成手順【SSHキー設定】

Posted at

github新規リポジトリ作成手順

githubの新規リポジトリ作成手順についての記事を備忘録として作成します。

git

gitに関する初期設定から行ったのでその時のメモを書いています。

gitインストール

macでターミナルを開き、ターミナルからgit --versionを実行。

コマンドラインツールのインストールをするか聞かれたのでインストールを実行。

コマンドラインインストール(15分程度)が完了し、git --versionを叩いたら無事使えるようになった。

$ git --version
git version 2.39.2 (Apple Git-143)

git config(ユーザー名・メールアドレス)

# ユーザー名を設定
git config --global user.name "ユーザー名"
# メールアドレスを設定
git config --global user.email "メールアドレス"

確認

git config user.name
atsuaa

git config user.email
xxxx@xxxx

SSHキー

SSHキーの設定について書いています。(ここが一番キライ、、)

sshキー作成

cd ~
mkdir .ssh
cd .ssh

ssh-keygen -t ed25519 -C "GitHubに登録したメールアドレス"

# Enter a file in which to save the key: ファイル名を入力
# 今回の場合
# github と入力して
# 秘密鍵:github, 公開鍵:github.pub の2つが作成された

# パスフレーズを入力
# もう一度パスフレーズを入力

ls
# github github.pub

ssh config作成

configファイルを作成する

pwd
# ~/.ssh
touch config
ls
# config github github.pub
vim config

configファイルに以下の内容を書いて保存(vimじゃなくてもエディタとかでおけ)

Host github
    Hostname github.com
    User git
    IdentityFile ~/.ssh/github

known_hosts

githubと疎通確認を行う際にknown_hostsに追加するか確認されるのでyesを選択してknown_hostsに追加する。

疎通確認コマンド

ssh -T github              
# The authenticity of host 'github.com (20.27.177.113)' can't be established.
# ED25519 key fingerprint is SHA256:+DiY3wvvV6TuJJhbpZisF/xxxxxxxxxxxxxxxxxxxx.
# This key is not known by any other names
# Are you sure you want to continue connecting (yes/no/[fingerprint])? yes [Enter]

公開鍵登録

githubにログインしたらプロフィールアイコンから[Settings]を選択。

スクリーンショット 2023-04-04 10.57.37.png

サイドメニューの[SSH and GPG keys]を選択し、[new SSH key]ボタンをクリック。

スクリーンショット 2023-04-04 10.58.54.png

[Title]は任意。
公開鍵を[Key]に貼り付ける。
公開鍵をクリップボードにコピーするコマンド。(ターミナル)
pbcopy < ~/.ssh/github.pub

スクリーンショット 2023-04-04 11.00.36.png

リポジトリ作成

リポジトリ作成については割愛します。

git clone から git push まで

作成したリポジトリをgit cloneし、テストファイルをコミット、git pushしたら無事pushされていることを確認。

参考

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