GIT - how to merge branches?

We decided to use GIT in our company, but now there is a problem. We have several branches with various functions. Now we need to combine these branches and push them to the Teacher. As we do this with autoreplace - we have branch-a, branch-b, branch-c - we need to get them all in Master, but in case of duplicate files, branch-b should be Major and branch-c-minor.

Upd:

branch-a:
-file1
-file2
-file3
-file4


branch-b:
-file1
-file5
-file6


branch-c:
-file1
-file2
-file7
-file8

we need the result:

Master:
-file1 (from b)
-file2 (from a)
-file3 (from a)
-file4 (from a)
-file5 (from b)
-file6 (from b)
-file7 (from c)
-file8 (from c)
+3
source share
4 answers

"-no-commit".

git merge --no-commit branch-a branch-b branch-c

, , , :

git checkout branch-b -- file3

.

git add . -A
git commit

.

, .

+10

, , :

git checkout master
git merge -s recursive -X theirs branch-c
git merge -s recursive -X theirs branch-a
git merge -s recursive -X theirs branch-b

recursive, , - , , . , git merge man ours theirs .

, , , , , . , ( , ), , , , :

git merge --no-commit branch-c

... , , . , , :

comm -1 -2 <(git ls-tree -r --name-only master|sort) <(git ls-tree -r --name-only branch-c|sort) > common.txt

... branch-c :

xargs -n 1 git checkout branch-c -- < common.txt

... git commit, .

, , - git , , .

+1

-

. . , , . .

( ), , , , , , .

- . . , - , , , git - , mergetool, kdiff3.

0

All Articles