git merge in one command

半城伤御伤魂 提交于 2020-01-16 04:09:06

问题


I'm now staying at branch-A. I want to merge branch-A into branch-B and switch to branch-B, how can I make this in one command?

Now I have to checkout branch-B ,and merge branch-A into itself. B/c I kept the IDE opened while merging.when I checkout another branch, the ide(xcode) can catch up the files' changing, and crashes usually. The merge I made usually goes with fast-forward.So I'm wondering if there is a way to make fast-forward merge without files' changing,just set the HEAD and branch-B(usually dev branch) to the lastest commit,thx


回答1:


Provided the merge is fast forward, you can solve the IDE problem by Merging to a branch in git without switching to it before switching to the merged-to branch. Then doing it in 1 command can be achieved by aliasing.




回答2:


I really don't see why it's such a hassle to type two commands:

git checkout branch-B
git merge branch-A

... but if it's really too "fussy" you could create a git alias to do this. For example, try:

git config alias.whevs '!sh -c '"'git checkout \"\$1\" && git merge HEAD@{1}'"

Then you can just do:

git whevs branch-B

That'll checkout the branch you supply as a parameter, and then merge in the previous commit that you were at.



来源:https://stackoverflow.com/questions/7272854/git-merge-in-one-command

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