0
0

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初心者が困り果てたからリポジトリごと削除することにした(Windows編)

Posted at

【完全ガイド】壊れた仮想環境・Git・GitHubリポジトリをまるごと整理してクリーンに再構築する方法(Windows編)

「.venvが壊れた」「Gitが変になった」「もう全部一回壊してやり直したい!」 そんなときに役立つ、ローカル環境とGitHubのリポジトリを一括整理して再構築する方法をまとめておきます。
実際に私も壊れてしまい初心者なので一度全て消そうと思い立ったのでメモ代わりに初投稿しておきます。


✅ ステップ①:ローカルのディレクトリを削除する(Windows)

PowerShell から、以下のコマンドでフォルダごと削除します。

Remove-Item -Recurse -Force "フォルダパス"

⚠️ フォルダの親ディレクトリを間違えて消さないように注意!もしくは、エクスプローラーで右クリック →「削除」でもOKです。

✅ ステップ②:Gitの紐付け(ローカル)だけ解除したい場合

Git管理を外すだけで、フォルダそのものは残したい場合は .git を削除します:

cd フォルダパス
Remove-Item -Recurse -Force .git

これでそのディレクトリはGit管理外の普通のフォルダになります。


✅ ステップ③:GitHub上のリポジトリを削除する

①GitHubで削除したいリポジトリのページを開く
 例:https://github.com/あなたのユーザー名/ae2dag

②上部メニューから Settings をクリック

➂下へスクロールし、[Danger Zone](危険地帯) まで移動

④「Delete this repository」をクリック

⑤表示されたリポジトリ名を入力

⑥「I understand the consequences...」にチェックを入れる

⑦「Delete this repository」をクリッ⑦

⚠️ 一度削除すると GitHub 上では復元できません!


🔁 ステップ④:クリーンに再スタートする方法

git clone https://github.com/あなたのユーザー名/リポジトリ名.git
cd リポジトリ名
python -m venv .venv
.\.venv\Scripts\Activate.ps1  # 仮想環境を有効化(Windowsの場合)
pip install -r requirements.txt  # 必要なパッケージをインストール

💡 .gitignore に .venv/ を追加して、仮想環境をGit管理対象から外すのを忘れずに!


✅ おまけ:よくあるトラブルを回避するTips

・PowerShellの実行ポリシーが原因で仮想環境が有効化できない場合:

Set-ExecutionPolicy RemoteSigned -Scope CurrentUser

・requirements.txt がない場合は、必要なパッケージを都度 pip install でインストールしてから以下で保存:

pip freeze > requirements.txt

🔚 おわりに

仮想環境やリポジトリの不具合は避けられないものですが、迷ったら一回壊して作り直すという選択肢があるだけで心が軽くなりました。今度はちゃんと動くように試すぞ・・・

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

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?