2013-05-27 5 views
5

मुझे आश्चर्य है कि * .user में एक .gitignore फ़ाइल जैसे साधारण पैटर्न और फ़ोल्डर नामों से मेल खाते हैं।* केवल * फाइलों को गिटिग्नोर कैसे करें?

ringods$ mkdir TestIgnore 
ringods$ cd TestIgnore/ 
ringods$ git init 
Initialized empty Git repository in /Users/ringods/Projects/hostbasket/TestIgnore/.git/ 
ringods$ git status 
# On branch master 
# 
# Initial commit 
# 
nothing to commit (create/copy files and use "git add" to track) 
ringods$ mkdir security.user 
ringods$ touch security.user/file_may_not_be_ignored.txt 
ringods$ git status 
# On branch master 
# 
# Initial commit 
# 
# Untracked files: 
# (use "git add <file>..." to include in what will be committed) 
# 
# security.user/ 
nothing added to commit but untracked files present (use "git add" to track) 
ringods$ echo "*.user"> .gitignore 
ringods$ cat .gitignore 
*.user 
ringods$ git status 
# On branch master 
# 
# Initial commit 
# 
# Untracked files: 
# (use "git add <file>..." to include in what will be committed) 
# 
# .gitignore 
nothing added to commit but untracked files present (use "git add" to track) 

क्या मुझे गलत उम्मीद है? मैं एक सरल एक्सटेंशन blah वाली फ़ाइलों को अनदेखा कैसे कर सकता हूं और में समाप्त होने वाले फ़ोल्डर को रोक सकता हूं .blah मिलान किया जा रहा है?

gitignore man page उल्लेख करता है कि शैल ग्लोब पैटर्न कार्यक्षमता का उपयोग करके मिलान किए बिना पैटर्न/मिलान किए जाते हैं, लेकिन यह वास्तव में मुझे नहीं बताता है कि यह केवल फाइलों या फ़ाइलों और निर्देशिकाओं से मेल खाता है या नहीं।

उत्तर

18

.gitignore पैटर्न निर्देशिका निर्देशिका या पथ से मेल खाते हैं। "केवल नियमित फ़ाइल से मिलान करें" कहने का कोई विशिष्ट तरीका नहीं है, हालांकि यदि आप पिछली / की आपूर्ति करते हैं तो पैटर्न केवल एक निर्देशिका से मेल खाता है। आप दो पैटर्न के साथ गैर-निर्देशिकाओं (जो लगभग आप चाहते हैं) से मेल खाने के लिए इसका उपयोग कर सकते हैं:

*.user  # ignore all paths ending in '.user' 
!*.user/ # but don't ignore these paths if they are directories. 
संबंधित मुद्दे