2016-01-05 6 views
5

मेरे पास एक php प्रोजेक्ट है जो पैकेज प्रबंधन के लिए संगीतकार का उपयोग करता है। पैकेजों में से एक एक ही प्रोजेक्ट से संबंधित एक और परियोजना है। मुझे अपने पूरे विक्रेता फ़ोल्डर को करने की आवश्यकता है, लेकिन मैं उप-प्रोजेक्ट में .git फ़ोल्डर को अनदेखा करना चाहता हूं ताकि इसे सबमिशन की तरह व्यवहार न किया जाए।गिट अनदेखा करें .git फ़ोल्डर

अब तक मुझे कोई सफलता नहीं मिली है। हालात मैं पहले से ही की कोशिश की है:

विक्रेता/.git

विक्रेता/**/Git/

Google खोज

ढेर अतिप्रवाह खोज


यहाँ क्या हो रहा है। उप-प्रोजेक्ट फ़ोल्डर गिटलैब में दिखता है। फ़ाइलों के बजाय, यह सिर्फ कुछ प्रकार का संदर्भ है।

enter image description here

+0

http://stackoverflow.com/questions/3240881/git-can-i-suppress-listing-of-modified-content-dirty-submodule-entries-in -स्टा –

+0

यह बहुत अच्छा होगा, सिवाय इसके कि मैं किसी भी पैकेज को submodules के रूप में उपयोग नहीं कर रहा हूं। असल में यही वह है जिसे मैं विशेष रूप से टालने की कोशिश कर रहा हूं। – bluemoonballoon

+0

'' '.gitignore''' –

उत्तर

1

ऐसा लगता है कि Git स्वचालित रूप से जड़ भंडार की सब-फ़ोल्डर के .git फ़ोल्डरों पर ध्यान नहीं देता।

आप निर्भरता के रूप में एक ही रिपोजिटरी से एक दूसरे प्रोजेक्ट लोड करते हैं, तो इस परियोजना के लिए एक अलग भंडार के लिए ले जाया जाना चाहिए:

(master)[/tmp] 
$ mkdir test_root 
(master)[/tmp] 
$ git init test_root 
Initialized empty Git repository in /tmp/test_root/.git/ 
(master)[/tmp] 
$ cd test 
test/  test_root/ 
(master)[/tmp] 
$ cd test_root/ 
(master)[/tmp/test_root] (master) 
$ ls 
(master)[/tmp/test_root] (master) 
$ git init test_child 
Initialized empty Git repository in /tmp/test_root/test_child/.git/ 
(master)[/tmp/test_root] (master) 
$ git status 
On branch master 

Initial commit 

nothing to commit (create/copy files and use "git add" to track) 
(master)[/tmp/test_root] (master) 
$ touch test_root_file 
(master)[/tmp/test_root] (master) 
$ cd test_child/ 
(master)[/tmp/test_root/test_child] (master) 
$ ls 
(master)[/tmp/test_root/test_child] (master) 
$ touch test_child_file 
(master)[/tmp/test_root/test_child] (master) 
$ cd .. 
(master)[/tmp/test_root] (master) 
$ git status 
On branch master 

Initial commit 

Untracked files: 
    (use "git add <file>..." to include in what will be committed) 

    test_child/ 
    test_root_file 

nothing added to commit but untracked files present (use "git add" to track) 
(master)[/tmp/test_root] (master) 
$ git add test_child/test_child_file 
(master)[/tmp/test_root] (master) 
$ git status 
On branch master 

Initial commit 

Changes to be committed: 
    (use "git rm --cached <file>..." to unstage) 

    new file: test_child/test_child_file 

Untracked files: 
    (use "git add <file>..." to include in what will be committed) 

    test_root_file 

(master)[/tmp/test_root] (master) 
$ cd test_child/ 
(master)[/tmp/test_root/test_child] (master) 
$ git status 
On branch master 

Initial commit 

Untracked files: 
    (use "git add <file>..." to include in what will be committed) 

    test_child_file 

nothing added to commit but untracked files present (use "git add" to track) 
(master)[/tmp/test_root/test_child] (master) 
$ git --version 
git version 1.9.1 
$ git add test_root_file 
(master)[/tmp/test_root] (master) 
$ git status 
On branch master 

Initial commit 

Changes to be committed: 
    (use "git rm --cached <file>..." to unstage) 

    new file: test_child/test_child_file 
    new file: test_root_file 

(master)[/tmp/test_root] (master) 
$ git commit -m'1 commit' 
[master (root-commit) 4d4b695] 1 commit 
2 files changed, 0 insertions(+), 0 deletions(-) 
create mode 100644 test_child/test_child_file 
create mode 100644 test_root_file 
(master)[/tmp/test_root] (master) 
$ git show 
commit 4d4b69589bf4f471c3c784f95f447d2a40ee6d7d 
Author: Evgenii Shchemelev 
Date: Wed Jan 6 09:20:03 2016 +0200 

    1 commit 

diff --git a/test_child/test_child_file b/test_child/test_child_file 
new file mode 100644 
index 0000000..e69de29 
diff --git a/test_root_file b/test_root_file 
new file mode 100644 
index 0000000..e69de29 
+0

हम्म। जब मैं सामान्य के रूप में प्रतिबद्ध और धक्का देता हूं, उप-प्रोजेक्ट रेपो में एक संदर्भ के रूप में दिखाई देता है, जबकि अन्य पैकेज (पैकेजिस्ट से) फ़ाइलों के रूप में दिखाई देते हैं। हालांकि अगर मैं मैन्युअल रूप से काम करने से पहले अपने उप-प्रोजेक्ट से .git dir को हटा देता हूं, तो सभी फाइलें अपेक्षित दिखाई देती हैं। शायद .git dir को अनदेखा करने की कोशिश करने से बेहतर तरीका है? – bluemoonballoon

+1

दरअसल, गिट फ़ोल्डर को अनदेखा करने का विचार गलत दिखता है। निश्चित रूप से अन्य तरीका होना चाहिए। मैंने आपके द्वारा वर्णित शर्तों के साथ प्रतिबद्ध करने की कोशिश की है - सब ठीक काम कर रहे हैं। प्रतिबद्धता में कोई संदर्भ नहीं है। हो सकता है कि आपके पैकेज वास्तव में आपके फाइल सिस्टम में मुलायम लिंक हों? –

+0

@YevgeniyShchemelev आपके परीक्षण का प्रयास करें जब '.git' उपनिर्देशिका घरों में एक जनसंख्या वाले गिट रेपो के लिए जानकारी रखती है। – user151841

2

मेरे लिए यह एक डिजाइन त्रुटि की तरह दिखता है।

A leading ** followed by a slash means match in all directories. For example, **/foo matches file or directory foo anywhere, the same as pattern foo . **/foo/bar matches file or directory bar anywhere that is directly under directory "foo".

तो आप निम्न कोड की कोशिश कर सकते हैं:

और अंदर विक्रेता निर्देशिका जगह के साथ

# Ignore Git here 
.git 

# But not these files... 
!.gitignore 
-1

प्रलेखन एक और .gitignore फ़ाइल अपने दोस्त

Git Documentation ने कहा कि है उपनिर्देशिका में .git फ़ोल्डर को अनदेखा करने के लिए:

**/.git/ 

मुझे यह भी आश्चर्य है कि आप इसे हटाने के बजाय फ़ोल्डर को अनदेखा क्यों कर रहे हैं।

+0

परीक्षण आपका मित्र है। क्या आपने इसे वास्तविक, आबादी वाले '.git' उपनिर्देशिका के साथ करने की कोशिश की है? – user151841

+0

@ user151841 कृपया मेरा दूसरा उत्तर देखें। मुझे विश्वास है कि –

-1

संपूर्ण vendor फ़ोल्डर को केवल .git उप-निर्देशिकाओं से अनदेखा किया जाना चाहिए। कौन से संकुल का उपयोग composer.json और composer.lock में संग्रहीत किया जाता है जो आप संस्करण नियंत्रण में जांचते हैं।

देखें:

ए) एक और रेपो

composer.json में जोड़े को संभालने के लिए संगीतकार का उपयोग करें: https://getcomposer.org/doc/faqs/should-i-commit-the-dependencies-in-my-vendor-directory.md

आप अपनी परियोजना के हिस्से के रूप में एक पुन: प्रयोज्य पैकेज बनाने के लिए चाहते हैं, तो आपके पास दो विकल्प हैं। ..

{ 
    "repositories": [ 
     { 
      "url": "https://github.com/l3pp4rd/DoctrineExtensions.git", 
      "type": "git" 
     } 
    ], 
    "require": { 
     "gedmo/doctrine-extensions": "~2.3" 
    } 
} 

बी) एक 2 संकुल निर्देशिका

आप एक packages निर्देशिका बनाने के लिए और अपने autoload रास्तों में जोड़ सकते हैं का प्रयोग करें। यह आप सभी कोड के लिए एक एकल Git रेपो का उपयोग करें (आप दो रेपोस उपयोग करना चाहते हैं, तो आप एक Git submodule उपयोग कर सकते हैं)

composer.json में जोड़े देंगे ...

"autoload": { 
    "classmap": ["packages"] 
} 
+0

मदद करता है डाउनवोट के कारण की व्याख्या करने के लिए? –

-1

उप इलाज नहीं करने के लिए एक सबमिशन के रूप में फ़ोल्डर, .git फ़ोल्डर हटाएं। ताकि आपको वेबसाइट में @number वाला फ़ोल्डर दिखाई नहीं दे। यदि आप सबमिशन को अपडेट करना चाहते हैं। आप में Shell

update.sh लिखा निम्नलिखित की तरह एक स्क्रिप्ट बना सकते हैं

git clone <url> <subfolder that you won't treat it as a module> 
rm -rf <subfolder>/.git/ 
git add <subfolder> 
git commit -m "Updated module" 

Update.bat

git clone <url> <subfolder> 
rmdir /s /q <subfolder>\.git 
git add <subfolder> 
git commit -m "Updated module" 

मेरा मानना ​​है कि यह सबसे अच्छा तरीका है GitLab में

@number से बचने के लिए है

आप इस प्रश्न का उत्तर देने के लिए मेरे GitHub repository को देख सकते हैं।

0

आप जो चाहते हैं उसे प्राप्त करने के लिए गिट हुक का उपयोग कर सकते हैं। बॉक्स से बाहर सोचकर, आप प्री-प्रतिबद्ध हुक का नाम बदलने के लिए उपयोग कर सकते हैं। आपकी शामिल प्रोजेक्ट की निर्देशिका, उदाहरण के लिए। ".git2" के लिए, ".git2" निर्देशिका को छोड़कर बाद की परियोजना में सभी फाइलें जोड़ें, सभी को प्रतिबद्ध करें, इसे दबाएं और आखिरकार पोस्ट-प्रतिबद्ध हुक का नाम बदलने के लिए ".git2" फ़ोल्डर का नाम बदलने के लिए ".git" में वापस जाएं। मॉड्यूल।

1) बनाएं पूर्व प्रतिबद्ध फ़ाइल तहत .git/हुक/सामग्री के साथ अपने जड़ रेपो की:

#!/bin/sh 
mv "vendor/modulename/.git" "vendor/modulename/.git2" 

git rm --cached vendor/modulename 
git add vendor/modulename/* 
git reset vendor/modulename/.git2 

2) बनाएं .git तहत फ़ाइल के बाद के लिए प्रतिबद्ध/हुक/ सामग्री के साथ:

#!/bin/sh 
mv "vendor/modulename/.git2" "vendor/modulename/.git" 

3) चैन जीई अपने रेपो में और अंत में एक फ़ाइल:

git commit -a -m "Commit msg" 
git push 
संबंधित मुद्दे