-1

I have a project with a layout like this:

folder_a
    folder_b
       file1.html
       file2.html
    folder_c
       file3.html
       file4.html
    folder_d
    .gitignore

Now, my goal is to include file3.html and the entire contents of folder_a/folder_b to .gitignore. To achieve this, I have written the following in .gitignore:

folder_b/
folder_c/file3.html

This seems elementary, and yet it doesn't work for me. The data still gets updated. What am I doing wrong? I've read the doc, and now it seems like I should write the full path, is it true? I am stuck.

Edgar Navasardyan
  • 4,261
  • 8
  • 58
  • 121

1 Answers1

1

The purpose of .gitignore is to exclude files from version control, not to prevent changes to files that are already in version control. Make sure that the files that you want to exclude are not in version control. You can do that without deleting the files on disk with commands like this:

git rm --cached folder_c/file3.html

And then commit the result.

Edit: It seems that OP wants to ignore new changes to files that are in version control. For that case there is a relevant answer on this question: How do I stop Git from tracking any changes to a file from this commit forward?

Jesse Hallett
  • 1,857
  • 17
  • 26
  • my goal is to to prevent changes, but I need the files to be present in the bitbucket – Edgar Navasardyan Dec 15 '18 at 20:57
  • 2
    In that case I think you want to use the answer from this question: https://stackoverflow.com/questions/18276951/how-do-i-stop-git-from-tracking-any-changes-to-a-file-from-this-commit-forward – Jesse Hallett Dec 15 '18 at 21:00