कई बार इस सवाल पर वापस आने के बाद भी मैं हमेशा इस पर अटक जाता हूं। मैं इसे चरणबद्ध तरीके से करने की एक विस्तृत प्रक्रिया के साथ आया हूं:
सबसे पहले उपयोग करें git add वास्तविक सामग्री जोड़ने के लिए करें।
यह अनुक्रमणिका में जोड़े गए प्रासंगिक फ़ाइलों को दिखाएगा जबकि अन्य सभी अभी भी अनट्रैक किए गए हैं। यह .gitignoreकदम से कदम को रोकने में मदद करता है ।
$ git add wp-content/themes/my-theme/*
$ git status
Changes to be committed:
new file: wp-content/themes/my-theme/index.php
new file: wp-content/themes/my-theme/style.css
Untracked files:
wp-admin/
wp-content/plugins/
wp-content/themes/twentyeleven/
wp-content/themes/twentytwelve/
...
wp-includes/
...
DUMMY.TXTअपनी निर्देशिका में एक अस्थायी फ़ाइल जोड़ें :
$ git status
Changes to be committed:
new file: wp-content/themes/my-theme/index.php
new file: wp-content/themes/my-theme/style.css
Untracked files:
wp-admin/
wp-content/plugins/
wp-content/themes/twentyeleven/
wp-content/themes/twentytwelve/
...
wp-content/themes/my-theme/DUMMY.TXT <<<
...
wp-includes/
...
हमारा लक्ष्य अब ऐसे नियमों का निर्माण करना है कि DUMMY.TXTजब हम कर रहे हैं तो यह अभी भी अनट्रैक के रूप में दिखाई दे रहा है।
नियम जोड़ना शुरू करें:
.gitignore
/*
पहले एक सब कुछ को अनदेखा करना है। अनट्रैक की गई फाइलें सभी चली जानी चाहिए, केवल अनुक्रमित फाइलें दिखनी चाहिए:
$ git status
Changes to be committed:
new file: wp-content/themes/my-theme/index.php
new file: wp-content/themes/my-theme/style.css
पथ में पहला डायर जोड़ें wp-content
/*
!/wp-content
अब अनट्रैक की गई फाइलें फिर से दिखाई देंगी, लेकिन केवल wp-content सामग्री है
$ git status
Changes to be committed:
new file: wp-content/themes/my-theme/index.php
new file: wp-content/themes/my-theme/style.css
Untracked files:
wp-content/plugins/
wp-content/themes/twentyeleven/
wp-content/themes/twentytwelve/
..
पहले डायर की हर बात को इग्नोर करें /wp-content/* और अन-!/wp-content/themes
/*
!/wp-content
/wp-content/*
!/wp-content/themes
अब अनट्रैक की गई फाइलें आगे चलकर केवल संकीर्ण हो जाएंगी wp-content/themes
$ git status
Changes to be committed:
new file: wp-content/themes/my-theme/index.php
new file: wp-content/themes/my-theme/style.css
Untracked files:
wp-content/themes/twentyeleven/
wp-content/themes/twentytwelve/
..
उस डमी फ़ाइल तक प्रक्रिया को दोहराएं जो अभी तक केवल अनट्रैक के रूप में दिखा रहा है:
/*
!/wp-content
/wp-content/*
!/wp-content/themes
/wp-content/themes/*
!/wp-content/themes/my-theme
$ git status
Changes to be committed:
new file: wp-content/themes/my-theme/index.php
new file: wp-content/themes/my-theme/style.css
Untracked files:
wp-content/themes/my-theme/DUMMY.TXT
**वाइल्डकार्ड केवल काम करता है यदि आपके पैटर्न में कोई स्लैश नहीं है, तो देखिए ।ththought.wordpress.com