2012-05-16 16 views
7

का उपयोग कर .gitignore बारे में कई प्रश्न पढ़ने के बाद सभी फ़ोल्डर में कुछ फ़ाइलों को अनदेखा मैं कोई भी उस मेरे सवाल का जवाब सकता है पाया है:एक भी .gitignore फ़ाइल

क्या मैं के साथ सभी फ़ाइलों को अनदेखा करने के लिए .gitignore में जोड़ने के लिए है एक निश्चित अंत, सभी फ़ोल्डर्स में *.txt कहें।

मैं शीर्ष स्तर पर केवल .gitignore फ़ाइल करना चाहता हूं।

मैंने कई चीजों की कोशिश की लेकिन कोई भी काम नहीं किया।

$ ls 
    abc.txt content 

    $ ls content/ 
    abc.txt def.other def.txt 

    $ echo "" > .gitignore 


    $ git status --ignored --untracked-files=all 
    # On branch master 
    # Changes not staged for commit: 
    # (use "git add <file>..." to update what will be committed) 
    # (use "git checkout -- <file>..." to discard changes in working directory) 
    # 
    #  modified: .gitignore 
    # 
    # Untracked files: 
    # (use "git add <file>..." to include in what will be committed) 
    # 
    #  abc.txt 
    #  content/abc.txt 
    #  content/def.other 
    #  content/def.txt 
    no changes added to commit (use "git add" and/or "git commit -a") 

यह आशा की जाती है के रूप में: सभी फाइलों को दिखाने के बाद से .gitignore खाली है

यह है कि मैं क्या (.gitignore भंडार से पहले, कोई अन्य फ़ाइल जोड़ा गया है करने के लिए जोड़ा गया था) का परीक्षण किया है।

$ echo "*.txt" > .gitignore 

    $ git status --ignored --untracked-files=all 
    # On branch master 
    # Changes not staged for commit: 
    # (use "git add <file>..." to update what will be committed) 
    # (use "git checkout -- <file>..." to discard changes in working directory) 
    # 
    #  modified: .gitignore 
    # 
    # Untracked files: 
    # (use "git add <file>..." to include in what will be committed) 
    # 
    #  content/def.other 
    # Ignored files: 
    # (use "git add -f <file>..." to include in what will be committed) 
    # 
    #  abc.txt 
    no changes added to commit (use "git add" and/or "git commit -a") 

फाइल सामग्री/abc.txt और content/def.txt सूची में क्यों नहीं दिखती है?

$ git clean -n 
    Would not remove content/ 

मैंने सोचा कि वे यहां भी दिखाई देंगे।

$ echo "" > .gitignore 

    $ git clean -n 
    Would remove abc.txt 
    Would not remove content/ 

    $ cd content 

    $ git clean -n -x 
    Would remove def.other 

    $ git clean -n -x 
    Would remove abc.txt 
    Would remove def.other 
    Would remove def.txt 

फ़ाइलें सामग्री/abc.txt और सामग्री/def.txt लेकिन clean -n द्वारा नहीं clean -n -x द्वारा दिखाए रहे हैं, तो मुझे लगता है कि वे ध्यान नहीं दिया जाता। लेकिन फिर वे git status --ignored --untracked-files=all में क्यों नहीं दिखते?

उत्तर

3

बस *.txt काम जोड़ रहा है। gitignore(5) man page को गिटिनोरोर प्रारूप स्पष्टीकरण के लिए

यदि आप content निर्देशिका जोड़ने का प्रयास करते हैं, तो सभी *.txt फ़ाइल को अनदेखा कर दिया जाएगा।

$ echo "*.txt" > .gitignore 

$ git add content 

$ git status --ignored --untracked-files=all 
# On branch master 
# 
# Initial commit 
# 
# Changes to be committed: 
# (use "git rm --cached <file>..." to unstage) 
# 
#  new file: content/def.other 
# 
# Untracked files: 
# (use "git add <file>..." to include in what will be committed) 
# 
#  .gitignore 
# Ignored files: 
# (use "git add -f <file>..." to include in what will be committed) 
# 
#  abc.txt 
#  content/abc.txt 
#  content/def.txt 
+1

ऐसा लगता है कि कारण है क्योंकि 'Git स्थिति --ignored --untracked-फ़ाइलें = all' अपने परीक्षण में उन फ़ाइलों को" निर्देशिका ट्रैक न हो "के साथ कुछ है नहीं दिखा रहा है (आप वास्तव में कर सकते हैं निर्देशिकाओं को ट्रैक न करें, बस फाइलें, लेकिन जब मैंने निर्देशिका के अंदर एक फ़ाइल को ट्रैक किया तो उन्होंने दिखाया) – KurzedMetal

+0

यह काम करता था। अजीब हालांकि कि 'गिट क्लीन-एफएक्स' फ़ोल्डर में केवल ट्रैक की गई फ़ाइल के बाद सामग्री में फ़ाइलों को हटा देता है। अन्यथा फ़ाइलों को हटाने के लिए मुझे फ़ोल्डर में कमांड को कॉल करना पड़ा! – Onur

संबंधित मुद्दे