owenmelbz
owenmelbz

Reputation: 6564

How to use Git Ignore on a self-emptying folder

I've got a git repo setup something like

Main
   -> Build
   -> Assets
   -> Resources

However, every time I compile our application, the "Build" directory gets completely wiped, thus deleting any .gitignore files within it.

How can I set a ignore to ignore that directory, from outside of it? something like:

Main/.gitignore

ignore /Build/*
ignore /Build

Many thanks

Update:

Our /Main/.gitignore looks like

### OSX ###
.DS_Store
.AppleDouble
.LSOverride
Icon


# Thumbnails
._*

# Files that might appear on external disk
.Spotlight-V100
.Trashes


### Build ###
# Build folder and log file
Build/
Build/**/*
build.log
build
npm-debug.log
tmp
.map

However SourceTree on OSX is still showing them as available to commit.

Upvotes: 1

Views: 234

Answers (1)

ThanksForAllTheFish
ThanksForAllTheFish

Reputation: 7251

It is enough to create the .gitignore file into your Main directory and write inside that file the entries of the directories you want to exclude.
For example, type in your terminal cd Main && echo "Build/" >> .gitignore (if you are using Linux).
Read this for other information: http://git-scm.com/book/en/Git-Basics-Recording-Changes-to-the-Repository#Ignoring-Files

Upvotes: 1

Related Questions