Home / Yazılım Geliştirme / .git Geçmişini Silmek

.git Geçmişini Silmek

mevcut bir repo’nun git geçmişini (git history) silmek istiyor sanız fakat kodun mevcut durumunun korunmasını istiyorsanız aşağıdaki durum tam sizlik.

  1. Checkout:
    git checkout --orphan latest_branch
  2. Add all the files:
    git add -A
  3. Commit the changes:
    git commit -am "commit message"
  4. Delete the branch:
    git branch -D main
  5. Rename the current branch to main:
    git branch -m main
  6. Finally, force update your repository:
    git push -f origin main

PS: this will not keep your old commit history around

Belirli bir git commit’ine çekip orada resetlemek isterseniz de başlangıçta onun hash’ine gitmek gerekecektir.
git reset --hard <sha1-commit-id>

Bir yanıt yazın

E-posta adresiniz yayınlanmayacak. Gerekli alanlar * ile işaretlenmişlerdir