Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
menu search
person
Welcome To Ask or Share your Answers For Others

Categories

I want to create repository for my Magento project. There are lots of folders and files in root directory and I change time to time only one folder: app/code/local/

Everything else I want to ignore. But.. can't. My .gitignore file:

*
!app/code/local/
!app/code/local/*

Then when I try to add folder to repo I get an error:

git add app/code/local/Mds/

The following paths are ignored by one of your .gitignore files:
app
Use -f if you really want to add them.
fatal: no files added

Can anyone please help with this?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
1.1k views
Welcome To Ask or Share your Answers For Others

1 Answer

Try below to ignore like you need:

/*
!/app/
/app/*
!/app/code/
/app/code/*
!/app/code/local/

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.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share

548k questions

547k answers

4 comments

86.3k users

...