Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

GIT: how to merge two branches without actually merging files (trivial merge)

Tags:

git

git-merge

Is there a way in git to merge two branches without merging file? In other words just to draw the merge arrow.

Let say I have branches A and B. I need to merge branch B to A, but no need all the changes in B, but rather only need to link to branches together.

git checkout A
git merge B --no need changes

In general is there a way to merge two branches without submodules. I want to keep submodules as it is in Branch A and still need to merge branch B.

like image 514
Ishan Liyanage Avatar asked Jun 15 '16 10:06

Ishan Liyanage


People also ask

How do I merge a branch without committing?

With --no-commit perform the merge and stop just before creating a merge commit, to give the user a chance to inspect and further tweak the merge result before committing. Note that fast-forward updates do not create a merge commit and therefore there is no way to stop those merges with --no-commit.

How do I merge 2 branches in git?

Merging Branches in a Local Repository To merge branches locally, use git checkout to switch to the branch you want to merge into. This branch is typically the main branch. Next, use git merge and specify the name of the other branch to bring into this branch.


1 Answers

Use git merge -s ours B to perform a merge discarding any changes B would introduce. Still, the commits from B are now in A, however, the files are at the state of A before the merge.

like image 118
Jonas Schäfer Avatar answered Sep 17 '22 14:09

Jonas Schäfer