2013-02-06 28 views
17

ब्रांच किए गए विलय के बाद मुझे conflict (rename/rename) फाइलों के समूह पर file~HEAD, और file~my_test_branch बनाया गया है। इन्हें कैसे हल करें?गिट विवाद (नाम बदलें/नाम बदलें)

धन्यवाद

+0

चुनें उन फ़ाइलों में से जो दिया फ़ाइलों में रहना चाहिए, और अन्य एक के साथ क्या करना है? या हाथ से अपनी सामग्री मर्ज करें, फिर परिणाम जोड़ें और विलय करें। – millimoose

+0

http://stackoverflow.com/questions/4679901/git-divergent-renaming यहां सहायता कर सकता है। – VonC

उत्तर

9

निम्नलिखित परीक्षण सेटअप को देखते हुए:

git init resolving-rename-conflicts 
cd resolving-rename-conflicts 
echo "this file we will rename" > will-be-renamed.txt 
git add -A 
git commit -m "initial commit" 
git checkout -b branch1 
git rename will-be-renamed.txt new-name-1.txt 
git commit -a -m "renamed a file on branch1" 
git checkout -b branch2 master 
git rename will-be-renamed.txt new-name-2.txt 
git commit -a -m "renamed a file on branch2" 
git checkout master 

फिर Branch1 और Branch2 विलय

git merge --no-ff branch1 
git merge --no-ff branch2 

पैदावार:

CONFLICT (rename/rename): Rename "will-be-renamed.txt"->"new-name-1.txt" in branch "HEAD" rename "will-be-renamed.txt"->"new-name-2.txt" in "branch2" 
Automatic merge failed; fix conflicts and then commit the result. 

git status 

On branch master 
You have unmerged paths. 
    (fix conflicts and run "git commit") 

Unmerged paths: 
    (use "git add/rm <file>..." as appropriate to mark resolution) 

    added by us:  new-name-1.txt 
    added by them:  new-name-2.txt 
    both deleted:  will-be-renamed.txt 

no changes added to commit (use "git add" and/or "git commit -a") 

आप एक रखना चाहते हैं फ़ाइल, 01 कहो:

git add new-name-2.txt 
git rm new-name-1.txt will-be-renamed.txt 
git commit 
बेशक

एक फ़ाइल या अन्य chosing में, आप फ़ाइलों द्वारा नाम इस फाइल का संदर्भ देने बनाने के लिए अन्य परिवर्तन हो सकता है। साथ ही, यदि फ़ाइल में अन्य गैर-नाम परिवर्तन हैं, तो शाखाओं पर प्री-या-पोस्ट का नाम बदलना है, तो आपको उन फ़ाइलों को मैन्युअल रूप से भिन्न करने और उन्हें उस फ़ाइल में बनाए रखने की आवश्यकता होगी, जिसे आप बनाए रखते हैं।

आप के बजाय दोनों फ़ाइलों को रखना चाहते हैं:

git add new-name-1.txt new-name-2.txt 
git rm will-be-renamed.txt 
git commit 
संबंधित मुद्दे