Githubへの公開とライセンス関連を調べた
https://github.com/Snowpooll/face_weather
が今回作成したもの
顔を認識するとVOICEVOXで今日の天気を教えてくれる
コンセプトは操作しないこと
アレクサでもいいけど
声が出せないと使えないし
以下は作業ログ
リポジトリ名を
face_weather
publicで公開
Add a README file
で
readmeを追加
ライセンスはMITライセンスを選択
これでリポジトリを作成すれば
ライセンスの英文は自動で作成してくれる
Readmeを編集してから
1 | git clone https: //github .com /Snowpooll/face_weather .git |
で
ローカル環境にリポジトリをクローン
この中にプログラムをコピーしていくが
1 | __pycache__ |
があった
これは
ChatGPTによれば
__pycache__ は、
Pythonがソースコードをコンパイルした後のバイトコードを格納するディレクトリ
バージョン管理システム(例:Git)を使用している場合は、
通常、__pycache__ ディレクトリを
無視リストに追加することが一般的
なので
1 | vim .gitignore |
でファイルを作成
1 | __pycache__/ |
として保存
1 | git add .gitignore |
で追加
1 | git commit -m "Add __pycache__ to .gitignore" |
を実行したら
1 2 3 4 5 6 7 8 9 10 11 12 13 | Author identity unknown *** Please tell me who you are. Run git config --global user.email "you@example.com" git config --global user.name "Your Name" to set your account's default identity. Omit --global to set the identity only in this repository. fatal: unable to auto-detect email address (got 'snowpool@snowpool-Prime-Series.(none)' ) |
となった
1 2 3 | そういえば再インストールした時に設定を忘れていたので git config --global user.name "ユーザ名" git config --global user.email "メルアド" |
で
再度
1 | git commit -m "Add __pycache__ to .gitignore" |
を実行
あと
1 2 3 | query.json test_audio.wav weather.txt |
も無視リストに加えるので
1 | vim .gitignore |
でファイルを開き
追記
1 2 | git add .gitignore git commit -m "Update .gitignore to include specific files" |
で追加
次に
1 | requirements.txt |
の作成
これでライブラリ関連のインストールが簡単になる
1 2 3 4 5 | requests deepl pygame opencv-python configparser |
というようにライブラリを書いておけばOK
1 | git push origin main |
でエラー。
1 2 3 | remote: Support for password authentication was removed on August 13, 2021. remote: Please see https: //docs .github.com /get-started/getting-started-with-git/about-remote-repositories #cloning-with-https-urls for information on currently recommended modes of authentication. |
調べたら
GitHubでパスワード認証が廃止されたため、
HTTPSを使ってリモートリポジトリにアクセスする際には
パーソナルアクセストークン(PAT)を使用するか、
SSHキー認証を使用する必要があるらしい
とりあえずPATを使うことにする
1 2 3 4 | GitHubでPATを生成する: * GitHubにログインし、右上のアカウントアイコンから「Settings」を選択します。 * 左側のサイドバーから「Developer settings」を選択し、「Personal access tokens」に移動します。 * 「Generate new token」をクリックし、必要な権限を選択してトークンを生成します。生成されたトークンは安全な場所にコピー |
で作成しようとしたら
New personal access token (classic)
の設定でつまづくので検索
https://dev.classmethod.jp/articles/github-personal-access-tokens/
によれば
Noteにはトークンの使用用途
code maintenanceとした
Expirationにはトークンの有効期限
デフォルトは30だが短いので90にする
Select scopesではトークンが利用可能なGitHub権限を設定
git cloneやgit pullをしたい場合は、repoにチェック
これで
Generate token
をクリックすれば
トークンが表示される
これで再度実行したら
1 2 3 4 5 6 7 | ! [rejected] main -> main (fetch first) error: failed to push some refs to 'https://github.com/Snowpooll/face_weather.git' hint: Updates were rejected because the remote contains work that you do hint: not have locally. This is usually caused by another repository pushing hint: to the same ref. You may want to first integrate the remote changes hint: (e.g., 'git pull ...' ) before pushing again. hint: See the 'Note about fast-forwards' in 'git push --help' for details. |
となる
原因は
リモートリポジトリにあなたのローカルリポジトリにはない変更が含まれているために発生
思い当たることとして
READMEを
Githubで編集した後に
1 | git pull origin main |
していなかったこと
他の変更はなかったため
1 | git push origin main --force |
で強制プッシュ
とりあえずはこれで公開できた
ちなみに後で聞いたのだが
–force は、remoteのものを完全に上書きするので、使わないほうがベター
必要なcommitが消える可能性があるらしい
認証も、SSHキーを使うのがベター
とのこと