109
95

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 3 years have passed since last update.

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

Last updated at Posted at 2018-11-24

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

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

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

109
95
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
109
95

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?