问题
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.
Update
git merge -s ours BRANCH_NAME worked for me.
回答1:
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.
回答2:
You can do a real merge and run git reset ORIG_HEAD --hard
to go back.
If you just want to have a try or study what happens after git merge
, you could make a series empty commits by git commit --allow-empty --allow-empty-message --no-edit
for several times. After you create the commits and branches, you can run git merge
and use gitk
or git log --oneline --graph
to see the commit graphic.
来源:https://stackoverflow.com/questions/37832988/git-how-to-merge-two-branches-without-actually-merging-files-trivial-merge