git merge in one command
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) t开发者_StackOverflow中文版o the lastest commit,thx
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.
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.
精彩评论