🛢️

【備忘録】GitHub最初にやっとく

2021/05/08に公開

概要

毎回わすれるので、備忘録

リポジトリ作成手順

  1. GitHubにアクセスしたいホストのユーザーで実行(前提条件)
  2. ssh-keygen でssh公開鍵作成
対話するのでEnter連打
cozftro@Zumi-MacBookAir ~ % ssh-keygen
Generating public/private rsa key pair.
Enter file in which to save the key (/Users/cozftro/.ssh/id_rsa): 
Created directory '/Users/cozftro/.ssh'.
Enter passphrase (empty for no passphrase): 
Enter same passphrase again: 
Your identification has been saved in /Users/cozftro/.ssh/id_rsa.
Your public key has been saved in /Users/cozftro/.ssh/id_rsa.pub.
The key fingerprint is:
SHA256:CpM0r9n4iBNbXb8gsd3vtYOw0Ob/Vc3V7DmfzRws518 cozftro@Zumi-MacBookAir.local
The key's randomart image is:
+---[RSA 3072]----+
|                 |
|               ..|
|    o           +|
|   . +. .     .o+|
|    +..=S+   . *=|
|  . .B+.+ *   +oB|
|   ++ o. = = ..oE|
|  o. o    + o..oo|
|  ... .    oo.o..|
+----[SHA256]-----+
cozftro@Zumi-MacBookAir ~ % 



2. ssh公開鍵の中身を確認

ssh公開鍵を確認
cozftro@Zumi-MacBookAir ~ % cat ~/.ssh/id_rsa.pub 
みせられないよ
cozftro@Zumi-MacBookAir ~ % 



3. GUIのGitHubに登録
Setting画面から左ペインの SSH and GPG keys をクリック

New SSH keyに先ほど確認した鍵を登録



4. git clone する

途中で対話が発生するので、yesを返す
cozftro@Zumi-MacBookAir GitHub % git clone git@github.com:Cozftro/python3_twitter.git
Cloning into 'python3_twitter'...
The authenticity of host 'github.com (52.192.72.89)' can't be established.
RSA key fingerprint is SHA256:nThbg6kXUpJWGl7E1IGOCspRomTxdCARLviKw6E5SY8.
Are you sure you want to continue connecting (yes/no/[fingerprint])? yes   ⇦ ここで yes を入力
Warning: Permanently added 'github.com,52.192.72.89' (RSA) to the list of known hosts.
warning: You appear to have cloned an empty repository.
cozftro@Zumi-MacBookAir GitHub % 



5. 確認

cloneコマンドを実行したカレントディレクトリにcloneできていることを確認
cozftro@Zumi-MacBookAir GitHub % ls -l
total 0
drwxr-xr-x  3 cozftro  staff  96  5  8 22:41 python3_twitter
cozftro@Zumi-MacBookAir GitHub % 

やっておくこと(詳細は割愛)

  • .gitignore
  • .github/PULL_REQUEST_TEMPLATE.md
  • .github/CODEOWNERS
  • プルリクエストMerge後の自動削除

元ネタ

https://docs.github.com/ja/github/getting-started-with-github/set-up-git

Discussion