Re: [git-users] Merge without replacing the outdated data.

2014-11-19 Thread Dmitry Moscow
Konstantin,
looks like I am missing something.

I got to branch A which I want to 'merge' (preserving the differencies) 
with branch B. 
I run git read-tree -m HEAD branch B
I get a number of files updated and added in my working folder. Files that 
were absent in branch A are added, the differenceis are applied. But 
unfortunately the differencies between the files are still erasing the old 
lines. I mean if there were difference in branch A and branch B on the same 
line in some file - after this command lines of that file in branch A where 
I run the command are replaced with lines from branch B. And there is no 
conflict. So it loooks like typical merge.

-- 
You received this message because you are subscribed to the Google Groups Git 
for human beings group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to git-users+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [git-users] Merge without replacing the outdated data.

2014-11-19 Thread Dale R. Worley
 From: Dmitry Moscow koktebelnig...@gmail.com

 I got to branch A which I want to 'merge' (preserving the differencies) 
 with branch B. 
 I run git read-tree -m HEAD branch B
 I get a number of files updated and added in my working folder. Files that 
 were absent in branch A are added, the differenceis are applied. But 
 unfortunately the differencies between the files are still erasing the old 
 lines. I mean if there were difference in branch A and branch B on the same 
 line in some file - after this command lines of that file in branch A where 
 I run the command are replaced with lines from branch B. And there is no 
 conflict. So it loooks like typical merge.

It seems to me that it would work to construct two working
directories, one for each branch.  Run diff -r --brief A B between
working directories, which will tell you all of the differences.  Copy
or merge what you desire from B into A, so that A is the merged file
tree that you desire.  Do git add in A to update the index to match
the working directory.  Do git write-tree to create a tree object in
the repository from the index.  Then do git commit-tree [hash of
tree] [head commit of A] [head commit of B] to create a new commit
containing the merged code and with the heads of A and B as parents.
Then use git branch -f [branch] [new commit hash] to set the head of
whatever branch you want to be the new commit.

Dale

-- 
You received this message because you are subscribed to the Google Groups Git 
for human beings group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to git-users+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [git-users] Merge without replacing the outdated data.

2014-11-18 Thread Konstantin Khomoutov
On Tue, 18 Nov 2014 05:26:08 -0800 (PST)
Dmitry Moscow koktebelnig...@gmail.com wrote:

 I have some special task which is definitely out of everyday git
 practices scope. Please let me know if its possible to accomplish
 this with some hacks.
 
 I have two branches of development of a single product. These two
 branches diverged long ago. Now its time to merge them. The idea is
 to merge them without losing functionality. This means I dont want
 merge them simply by selecting most up-to-date version, I want BOTH
 versions to be present in case there are some difference between the
 files. 
 
 I.e. if some file differs in two branches - I want to raise a
 conflict to merge it manually. Note, that if file to merge has
 different versions in braches to merge - this does not necessarily
 forces Git will to raise a conflict. It will do it ONLY if there were
 conflicting changes after the branch separation point. This may not
 be my case all the time. For example, in this situation Git will do
 merge without a conflict, and I will just lose the branch A
 functionality in the lines 34 and 67. But I want to preserve ALL
 functionality from both branches:
[...]

You could try going one level deeper and use `git read-tree` instead:

  git read-tree -m HEAD branch_to_merge

This command should only update the index and do not touch the work
tree.  So any files with conflicts will be marked in the index as such
(with their sides available).

Note that this command creates a situation of the work tree being not
consistend with the index.  I mean, if the merge operation added some
files, they'll be missing from the work tree, and if it deleted some
files (which our side did not touch, so it's fine to delete them),
they'll be present in the work tree and deemed to be untracked by
`git status`.
Hence after fixing the conflicts you'll want to use
`git checkout-index` to update the work tree to the actual post-merge
state.

-- 
You received this message because you are subscribed to the Google Groups Git 
for human beings group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to git-users+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.