LoginSignup
106
93

More than 1 year has passed since last update.

Gitのリポジトリ(履歴)を初期化する

Last updated at Posted at 2018-11-24

リポジトリのURLはそのままで、履歴を完全削除したい。
(公開前の準備履歴を消したいときのメモ。必要になることは少ないと思う。)

  1. remoteのURLを保存 git remote -v
  2. rm -rf .git
  3. フォルダを綺麗にして、新規にInitial commitしたい内容にする。
  4. git init
  5. git add .
  6. git commit -a -m"Initial Commit"
  7. git remote add origin {手順1のURL}
  8. "-f"でリモート側の履歴が強制的に上書きされるので注意。git push -u origin main -f

これで、リモートリポジトリに"Initial Commit"のコミット履歴だけがある状態になる。

106
93
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
106
93