2010-07-24 23 views
13

मैंGit submodule

git clone git://github.com/psynix/rails3_haml_scaffold_generator.git lib/generators/haml 

के साथ 3 परियोजना मेरी रेल के लिए कुछ Haml टेम्पलेट जोड़े केवल, लगता है जब मैं उन फ़ाइलों में से कुछ को संपादित करने की कोशिश की से छुटकारा पाने के नहीं किया जा सकता है कि यह एक submodule था, इसलिए मैं lib/generators/haml निर्देशिका में किए गए परिवर्तन नहीं कर सका। अब हर बार जब मैं git status, मैं

# On branch master 
# Changed but not updated: 
# (use "git add <file>..." to update what will be committed) 
# (use "git checkout -- <file>..." to discard changes in working directory) 
# 
# modified: lib/generators/haml 
# 
no changes added to commit (use "git add" and/or "git commit -a") 

लेकिन git add lib/generators/haml कोई प्रभाव नहीं है। मैं वास्तव में सिर्फ फाइलें, नहीं एक submodule करना चाहते हैं, लेकिन मैं खोजने हूँ submodule असंभव से छुटकारा पाने के:

> git rm --cached lib/generators/haml 
rm 'lib/generators/haml' 
> git status 

# Changes to be committed: 
# (use "git reset HEAD <file>..." to unstage) 
# 
# deleted: lib/generators/haml 
# 
# Untracked files: 
# (use "git add <file>..." to include in what will be committed) 
# 
# lib/generators/ 

> git commit -m "Removed submodule" 

[master 02ae4c7] Removed submodule 
1 files changed, 0 insertions(+), 1 deletions(-) 
delete mode 160000 lib/generators/haml 

> git status 

# On branch master 
# Your branch is ahead of 'origin/master' by 1 commit. 
# 
# Untracked files: 
# (use "git add <file>..." to include in what will be committed) 
# 
# lib/generators/ 
nothing added to commit but untracked files present (use "git add" to track) 

> git add lib/generators/haml 
> git status 

# Changes to be committed: 
# (use "git reset HEAD <file>..." to unstage) 
# 
# new file: lib/generators/haml 
# 
# Changed but not updated: 
# (use "git add <file>..." to update what will be committed) 
# (use "git checkout -- <file>..." to discard changes in working directory) 
# 
# modified: lib/generators/haml 

> git commit -m "Re-added lib/generators/haml" 

[master c966912] Re-added lib/generators/haml 
1 files changed, 1 insertions(+), 0 deletions(-) 
create mode 160000 lib/generators/haml 

> git status 

# Changed but not updated: 
# (use "git add <file>..." to update what will be committed) 
# (use "git checkout -- <file>..." to discard changes in working directory) 
# 
# modified: lib/generators/haml 

अतिरिक्त git add रों बेकार हैं। अगर मैं git rm -rf lib/generators/haml कोशिश, मैं

fatal: git rm: 'lib/generators/haml': Operation not permitted 

यह सिर्फ मर नहीं मिलता! मैंने how to delete submodules देखा है, लेकिन इस मामले में, .submodules फ़ाइल नहीं है, और न ही .git/config में सबमिशन का कोई उल्लेख है। फिर भी अगर मैं git submodule update चलाने के लिए, मैं

No submodule mapping found in .gitmodules for path 'lib/generators/haml' 

मैं निर्देशिका नष्ट कर दिया है, लेकिन मैं एक ही परिणाम प्राप्त! क्या चल रहा है? क्या मुझे सबमिशन को हटाने के लिए .gitmodules फ़ाइल बनाने की आवश्यकता है?

उत्तर

6

अगर कोई submodule है, यह संभव है कि यह (यानी 'haml') वास्तव में नहीं है:

नवीनतम Git संस्करण (1.7.1, मुझे लगता है) की स्थिति में यह जानकारी से पता चलता एक सबमिशन?

git clone git://github.com/psynix/rails3_haml_scaffold_generator.git lib/generators/haml 

का अर्थ है: git://github.com/psynix/rails3_haml_scaffold_generator.git के मालिक शाखा उस में lib/generators/haml निर्देशिका, और चेकआउट पैदा करते हैं।

तथ्य यह है कि आप एक git status अपने नए रेपो (lib/generators/haml) की जड़ से नहीं कर सकते हैं, लेकिन इसके बाद के संस्करण तीन स्तरों (जहां lib है) का अर्थ है कि आप एक रेपो के भीतर एक रेपो क्लोन है।

दोनों रिपो स्वतंत्र रूप से काम कर सकते हैं, लेकिन आपको lib/generators/haml को .gitignore में माता-पिता रेपो (जैसे हिट SO question) में जोड़ना चाहिए।

+0

धन्यवाद, इसे '.gitignore' में जोड़ना एक अच्छा विचार था। –

+1

लेकिन यह नई फ़ाइलों को रेपो में नहीं दबाएगा, एफवाईआई – andho

+0

मेरी समस्या असंबद्ध हो गई, लेकिन इससे मदद मिली। –

6

सबमिशन गिट स्थिति में दिखाया गया है क्योंकि इसमें अनचाहे फ़ाइलें हैं।

diff --git a/lib/generators/haml b/lib/generators/haml 
index 3019fec..653c59a 160000 
--- a/lib/generators/haml 
+++ b/lib/generators/haml 
@@ -1 +1 @@ 
-Subproject commit 653c59ad72925c9ccbde67e8e484e15d4b6dd25d 
+Subproject commit 653c59ad72925c9ccbde67e8e484e15d4b6dd25d-dirty 

इसका मतलब है कि इस submodule के अंदर कुछ ट्रैक न किए गए छोड़ दिया फ़ाइलें हैं: आप git diff lib/generators/haml आह्वान हैं, तो आप सबसे कुछ इस तरह दिखाई likeyl करेंगे। उन्हें मूल परियोजना में आदेशों के माध्यम से जोड़ा नहीं जा सकता है; इसके बजाय आपको sumbodule में जाना चाहिए और उन्हें जोड़ना चाहिए (या .gitignore में प्रविष्टियां जोड़ें) ... या आप केवल स्थिति संदेश को अनदेखा कर सकते हैं।

# Changed but not updated: 
# (use "git add <file>..." to update what will be committed) 
# (use "git checkout -- <file>..." to discard changes in working directory) 
# 
# modified: lib/generators/haml (untracked content) 
+0

ठीक है, मुझे लगता है कि मैं समझता हूं: मुझे 'lib/generators/haml' में जाना चाहिए और फिर जब भी मैं वहां कुछ बदलता हूं वहां से गिट सामान लेना चाहिए। जैसा कि आपने सुझाव दिया था, मैंने अपना गिट 1.7.0.5 से 1.7.2 तक अपडेट किया है, और यह मुझे और अधिक उपयोगी संदेश देता है। यह अभी भी मेरे दिमाग को उड़ाता है कि गिट ने सोचा था कि 'lib/generators/haml'along को' .git' निर्देशिका के साथ दूर करने के बाद भी एक सबमिशन था। –

0

आप इस्तेमाल किया जा सकता था:

git add lib/generators/haml/ 

सिर के submodule में फ़ाइलों को जोड़ने के लिए और submodule दूर करने के लिए।लेकिन फिर यह काम नहीं कर सकता क्योंकि आपके पास वास्तव में एक सबमिशन नहीं है।

ध्यान दें कि पथ के पीछे एक पिछला स्लैश है।

git add lib/generators/haml 

जो सिर्फ बदल जाएगा Git submodules में submodule से जाँच की जानी करने के लिए प्रतिबद्ध: यदि आप इस Git submodule दूर करता है और यह सिर में डालता है, के विपरीत डाल दिया।

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