# Git geçmişinden dosya temizleme

![](https://i.imgur.com/0bg0fM3.png)

```bash
FILENAME=""

git filter-branch --force --index-filter \
"git rm --cached --ignore-unmatch $FILENAME" \
--prune-empty --tag-name-filter cat -- --all

git push origin --force --all
git push origin --force --tags
git for-each-ref --format='delete %(refname)' refs/original | git update-ref --stdin
git reflog expire --expire=now --all
git gc --prune=now
```

* `FILENAME=""` ile temizlemek istediğiniz dosyanın adını belirtin.
* `git filter-branch` komutu ile Git geçmişinde belirli bir dosyanın tüm izlerini temizleyebiliriz.
* `-force` parametresi, filtre dalının zaten var olduğu durumlarda hata vermemesi için kullanılır.
* `-index-filter` parametresi, her bir commit için çalıştırılan komutu belirtir.
* `git rm --cached --ignore-unmatch $FILENAME` komutu ile belirtilen dosyanın tüm versiyonlarını kaldırırız.
* `-prune-empty` parametresi, dosya değişikliği içermeyen boş commit'leri kaldırır.
* `-tag-name-filter cat -- --all` parametresi, tüm dallar ve etiketler üzerinde işlem yapar.
* `git push origin --force --all` ve `git push origin --force --tags` komutları ile değişiklikleri uzak depoya zorla push ederiz.
* `git for-each-ref --format='delete %(refname)' refs/original | git update-ref --stdin` komutu ile orijinal referansları sileriz.
* `git reflog expire --expire=now --all` ve `git gc --prune=now` komutları ile git geçmişini temizleriz.


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.yemreak.com/arsiv/programming/git-gecmisinden-dosya-temizleme.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
