Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
598 views
in Technique[技术] by (71.8m points)

magento - Git ignore all except subfolder

I searched through other questions but can't find a working solution for my project. Having a Magento project, I want to exclude everything except this:

/app/design/frontend/default/theme_name # and obviously all subfolders
/skin/frontend/default/theme_name # and all subfolders

I've tried a lot of combinations but without luck. Currently I'm stuck with this .gitignore file:

*
!/app/
!/app/*

app/*
!/app/design/
!/app/design/*

But it doesn't work recursively below the design folder. It only added a test file inside the design folder that I created.

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

Look at my answer here: Can't understand how gitignore ignores the folders

Quoting from that:

The following discussion was helpful: http://git.661346.n2.nabble.com/negated-list-in-gitignore-no-fun-td1675067.html , especially the following from Linus:

That's by design. You've chosen to ignore those directories; they match "*" themselves. Thus, 'git add .' doesn't descend into them looking for files.

So basically, for each level you have to go in, unignore that folder, and ignore contents within that folder.

Also, you should look at having .gitignore at subdirectory rather than at root level only as it becomes pretty complex if you have to go to the subdirectory level from the root .gitignore because of the explanation above, whereby for each level, you have to unignore the folder and then ignore the contents and so on.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...