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

倖福魔咒の 提交于 2021-01-21 06:48:06

问题


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

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!