2
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?

Githubに機密情報をアップしてしまった際の超簡易的な対処方法

Posted at

GitHubにプッシュした直後、apiKeyをハードコーディングしたままだったことに気づいたので、最速(20秒くらい)で消した手順をまとめます。

手順

  1. apiKeyを削除する
  2. 以下のコマンドを実行
git add . # 変更をステージする
git commit --amend --no-edit # 直前のコミットに対してステージした内容を追加する
git push -f origin HEAD # ローカルのコミット内容をリモートに強制反映する

注意点

この方法は、直前のコミットにのみ機密情報が含まれている場合に限り有効です。

また、どこかに履歴が残っている可能性があるため、アップロードしてしまったapiKeyなどは必ず削除してください。

おまけ

GitHubの場合、機密情報をプッシュした時点で通知を飛ばしてくれます。

スクリーンショット 2025-07-28 16.42.48.png

2
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
2
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?