Indexlenmiş bir kaç tane dosya var ama, içlerinden bir tanesini committen etkilenmesin diye indexten kaldırmak istiyorsunuz. Dosyanın değişiklikleri olduğu gibi kalıyor. Bu işlem için git rm --cached komutu kullanılır ama "untracked" dosyaları kapsamaz. Daha fazla bilgi için git rm linkini tıklayın.


Mevcut durumu kontrol edelim


inanzzz@inanzzz:~/project$ git status
On branch develop
Changes to be committed:
(use "git reset HEAD <file>..." to unstage)

new file: file_five.txt
modified: file_three.txt

Changes not staged for commit:
(use "git add/rm <file>..." to update what will be committed)
(use "git checkout -- <file>..." to discard changes in working directory)

deleted: file_one.txt
modified: file_two.txt

Untracked files:
(use "git add <file>..." to include in what will be committed)

file_four.txt

Dosyayı indexten kaldırmak


inanzzz@inanzzz:~/project$ git rm --cached file_three.txt
rm 'file_three.txt'

Mevcut durumu kontrol edelim


Göründüğü gibi "file_three.txt" dosyası "deleted" olarak işaretlenmiş ve "untracked" bölümüne alınmış, bu nedenle dosyadaki değişiklikler committen etkilenmeyecek.


inanzzz@inanzzz:~/project$ git status
On branch develop
Changes to be committed:
(use "git reset HEAD <file>..." to unstage)

new file: file_five.txt
deleted: file_three.txt

Changes not staged for commit:
(use "git add/rm <file>..." to update what will be committed)
(use "git checkout -- <file>..." to discard changes in working directory)

deleted: file_one.txt
modified: file_two.txt

Untracked files:
(use "git add <file>..." to include in what will be committed)

file_four.txt
file_three.txt

Commit


inanzzz@inanzzz:~/project$ git commit -m 'Commit'
[develop 4cb186c] Commit
2 files changed, 1 insertion(+), 2 deletions(-)
create mode 100644 file_five.txt
delete mode 100644 file_three.txt

Mevcut durumu kontrol edelim


Göründüğü gibi "file_three.txt" dosyası halen "untracked" ve committen etkilenmemiş durumda.


inanzzz@inanzzz:~/project$ git status
On branch develop
Changes not staged for commit:
(use "git add/rm <file>..." to update what will be committed)
(use "git checkout -- <file>..." to discard changes in working directory)

deleted: file_one.txt
modified: file_two.txt

Untracked files:
(use "git add <file>..." to include in what will be committed)

file_four.txt
file_three.txt

no changes added to commit (use "git add" and/or "git commit -a")