My Technical Notes

Wednesday, 24 June 2015

Git: Ignoring files

given a folder `fold` with the structure:

  • fold
    • yakult.txt
    • people
      • sepp_blatter.txt
      • emile_heskey.txt
    • bin
      • gen.xml
      • gen.dll

To ignore `yakult.txt`, we must place a `.gitignore` file within its parent `fold` with the following content:


yakult.txt

To ignore all text files within `people` folder, we need to add a `.ignore` within people with:


*.txt

To add the `bin` folder, but ignore all files within it, we add a `.gitignore` file with:


*
!.gitignore

The first line ignores all files, and the second line says except (exclamation) the `.gitignore` file.

To ignore the `bin` folder altogether, we need to add a forward slash at the end to say that it is a folder:


bin/

No comments: