squash - In git how can I commit to master without merging? -
squash - In git how can I commit to master without merging? -
tl;dr; want way tell git "master has new revision looks same tip of feature a, without history".
is there way this?
[update: have workflow minimizes problem, still know how tell git following:-
commit single alter branchx, create files , folders match @ tip of branch y. possible?]
the story
we avoid branching feature branches.. had in case. here tried :-
master o-----------------o---------------o \ /[squash] / feature o-o-o-o-o-o-o-o / [squash] -- many conflicts \ / feature b o-o-o-o-------------o
for various reasons squish onto master. feature b had bunch of changes in mutual feature a, sec squish had lots of merge conflicts.
i tried this...
master o-----------------o----------------o \ /[squash] / [squash] -- same set of conflicts!! feature o-o-o-o-o-o-o-o----------------o \ / (merge) -- easy feature b o-o-o-o--------------o
the (merge) easy, , left feature set of files want master have (as feature , master had same files after merged master). merge easy git knew conflicts after feature b branched needed resolving.
at point want commit merged feature branch master. same set of conflicts trying avoid.
feature has changes want... check out master , feature , re-create files master, commit. in fact that's ended doing... certainly there way git?!?
i tried generating binary patch master feature a , applying it.
git diff --binary master featurea > patch git apply patch
this failed "patch not apply" errors.
i tried various other effort merge... resulting in me having resolve same merge conflicts resolved on again.
the reason merge pain feature b master files changed in feature before feature b branched farther changed feature before commit. means git sees these files changed in feature b, differ committed in feature a, merge required.
rebasing feature b on master before committing mean 1 time again have perform merging of file haven't touched.
there more 1 way resolve issue git, one of mutual methods rebase branch b onto master branch, before attempting merge it.
assume x shared mutual ancestor commit between branches , b. then
rebase b onto master
git rebase --onto master x b
that take commits after x , leading b, , re-apply them on top of master branch. you'll need resolve conflicts still, you'll resolve them in smaller chunks because re-apply commits 1 one.
next, can crush branch b using soft reset, followed commit (note not way crush b):
class="lang-bash prettyprint-override">git reset --soft x git commit -m "squashing b"
note can reverse steps #1 , #2. difference squashing b first, you'll end having resolve conflicts @ 1 time 1 time again after rebase.
merge b master,
git checkout master git merge b
alternatively steps #2 , #3 above, if did step #1, can utilize git merge --squash
crush , merge branch b,
git checkout master git merge --squash b git commit -m "squashed , merged b"
git squash
Comments
Post a Comment