tags:

views:

111

answers:

3

want to get file_3 by merging file_1 and file_2

if manual merge needed, text editor or merge tools can be used. preferably file_3 is in git merge like format.

file_1 is in git, but both with or without git to do the merge is fine

on Linux.

A: 
cat file1 file2 > merged_file
kingsindian
this is just CATenate 2 files not merge.what I mean is merge 2 versions of the same file. like git merge on branches.
madcat
+1  A: 

If you use git, you could:

(Let's assume that the master branch contains the file1)

  • create a new branch, git co -b 0001-merging-one-file
  • overwrite file1 in this branch with file2, via editor or by any other means ..
  • checkout master again, git co master
  • merge your 'temporary branch' into master, git pull . 0001-merging-one-file
  • no step 5 ;)
The MYYN
is it possible to pull from master to temp branch. since this is temporary merge, don't want to affect master...
madcat
yes, it should be possible .. the procedure would stay similar
The MYYN
it tells already up-to-date. file 2 should not be committed to temp branch?
madcat
A: 

For the 3-way merging git uses you need THREE versions of the file: "ours" version, "theirs" version, i.e. versions you want to merge, but you also need "common" version, i.e. version of file that was common source for "ours" and "theirs" version; for Git it would be version from merge base of current branch and the branch you are merging.

The algorithm and the way to mark merge conflicts Git uses is nearly the same as the one used by rcsmerge tool from RCS (long time ago Git required rcsmerge installed), and by diff3 -E. You can run it by hand using low level (plumbing) command git merge-file.

Jakub Narębski