Pernahkah anda mencoba meng-ignore file atau folder di repository git, tetapi file tersebut masih bisa diubah dan ikut kedalam repository.
Contoh kita buat repository kosong
mkdir ~/git-jaranguda cd ~/git-jaranguda git init
buat beberapa file
touch file{1..5}.html # file yang dihasilkan # file1.html file2.html file3.html file4.html file5.html
buat file .gitignore yang berisi file1.html
echo "file1.html" > .gitignore
normalnya bila anda menambah file di .gitignore, saat mencoba menambah file tersebut ke index harusnya muncul pesan error
$ git add file1.html The following paths are ignored by one of your .gitignore files: a1 hint: Use -f if you really want to add them. hint: Turn this message off by running hint: "git config advice.addIgnoredFile false"
tetapi bila file tersebut duluan ada dan sudah ditambah kedalam index git dengan perintah git add namafile, maka pesan tersebut tidak akan muncul.
git add file2.htmltambahkan file2.html tersebut kedalam gitignore
echo "file2.html" >> .gitignore
coba jalankan git add
git add file2.htmlSolusi atas masalah ini adalah dengan menghapus file yang akan di ignore tersebut lalu tambahkan nama filenya di .gitignore
git rm file2.html # bila belum ada file2.html di .gitignore tambahkan denga echo "file2.html" >> .gitignore
lalu coba lagi ditambah dengan git add file2.html
The following paths are ignored by one of your .gitignore files: .file2.html hint: Use -f if you really want to add them. hint: Turn this message off by running hint: "git config advice.addIgnoredFile false"