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?

[Qiita] Git連携 - 基本

Last updated at Posted at 2025-01-03

要約

手順

Qiita

  1. Qiitaのトークンを発行
    1. 設定 -> アプリケーション -> 個人用アクセストークンから「新しくトークンを発行する」を選択
      image.png
    2. トークンの設定を入力
      アクセストークンの説明はGitHub用と判別可能な任意のテキストを入力
      スコープは「read_qiita」と「write_qiita」を選択
      image.png
    3. 発行されたトークンをコピー
      image.png

GitHub

  1. GitHubレポジトリの作成
    image.png
  2. GitHub Actionsの設定
    1. Settings -> Secrets and variables -> Actions -> Secretsから「New repository secret」を選択
      image.png
    2. シークレットの設定
      NameにQIITA_TOKENを入力
      Secretに1-3で発行したトークンを入力
      image.png
      image.png

Qiita CLI

  1. インストール

    1. qiita-cli
      1. npm install @qiita/qiita-cli --save-dev
        image.png
  2. セットアップ

    1. npx qiita init
    2. npx qiita login
      ※恐らくログイン時にはGitHubとは別のトークンを入力するのがベストプラクティス。ここでは同一のトークンを入力
      image.png

GitHubレポジトリと同期

  1. リモートレポジトリの追加
    git init
    git add *
    git commit -m "first commit"
    git branch -M main
    git remote add origin [リポジトリのURL]
    
  2. リモートレポジトリのPush
    git push -u origin main
    image.png
  3. GitHubレポジトリ
    image.png

所感

  • Qiita CLIは特に問題なかったが、以下のことからGitHubの操作方法でハマった。業務では漫然とGitを使用していたと反省。Gitを学びなおしたほうがいいかもしれない
    • 普段はAzure DevOpsのReposを使用しており、Repos上からレポジトリを作成->Cloneをしている
    • VSCode上からコミット・Pushをしており、コマンドラインの操作方法が不明だった
  • Node.jsを使用するため、Devcontainerとして使用したい。Devcontainerは数回使用したことがあるがいまいち理解していないので理解しながら設定する(ToDo: 1)
    • 主旨は環境を汚染したくないため
    • 元々PCにはNode.js v14がインストールされていた(使用していないが)
    • Qiita CLIのインストールに伴いv22をインストールし直した
  • PCに設定されているGitの設定がAzure DevOps Repos用のため設定変更が必要。複数アカウントを使い分けられるように設定する必要がある(ToDo: 2)
    • 今回は面倒になったためユーザ情報をGitHub用に書き換えてしまった
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?