मैं एक इंटरैक्टिव रिबेस के दौरान दो विलय प्रतिबद्धताओं को स्क्वैश करने का एक आसान समाधान चाहता था।गिट रिबेस इंटरैक्टिव: स्क्वैश विलय एक साथ काम करता है
मेरे भंडार लगता है:
X --- Y --------- M1 -------- M2 (my-feature)
/ / /
/ / /
a --- b --- c --- d --- e --- f (stable)
है कि, मैं, एक my-feature
शाखा है, जो दो बार हाल ही में विलय कर दिया गया है से कोई वास्तविक के बीच में करता है। मैं नहीं है सिर्फ my-feature
शाखा rebase करने के बाद से यह अपने आप में एक प्रकाशित शाखा है चाहता हूँ, मैं सिर्फ एक साथ छुटकारा पाने के लिए पिछले दो मर्ज में प्रतिबद्ध चाहते हैं (अभी तक उन प्रतिबद्ध प्रकाशित नहीं किया है)
X --- Y ---- M (my-feature)
/ /
/ /
a --- ... -- f (stable)
मैंने कोशिश की:
git rebase -p -i M1^
लेकिन मुझे मिल गया:
Refusing to squash a merge: M2
क्या मैं अंत में किया है:
git checkout my-feature
git reset --soft HEAD^ # remove the last commit (M2) but keep the changes in the index
git commit -m toto # redo the commit M2, this time it is not a merge commit
git rebase -p -i M1^ # do the rebase and squash the last commit
git diff M2 HEAD # test the commits are the same
अब, नए विलय प्रतिबद्धता को अब विलय प्रतिबद्धता नहीं माना जाता है (यह केवल पहले माता-पिता को रखा गया है)। तो:
git reset --soft HEAD^ # get ready to modify the commit
git stash # put away the index
git merge -s ours --no-commit stable # regenerate merge information (the second parent)
git stash apply # get the index back with the real merge in it
git commit -a # commit your merge
git diff M2 HEAD # test that you have the same commit again
लेकिन अगर मेरे पास बहुत से काम हैं तो यह जटिल हो सकता है, क्या आपके पास बेहतर समाधान है? धन्यवाद।
मिल्ड्रेड
खैर, जब लागू होगी आप अपना दूसरा विलय करें, आप हमेशा प्रतिबद्धता बनाने से बचने के लिए '--squash' का उपयोग कर सकते हैं, और उसके बाद पिछले विलय को संशोधित करने के लिए 'git commit --amend' का उपयोग करें। – Mildred
यह काम नहीं करेगा, यह – Mildred