1

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

user392412
  • 743
  • 12
  • 18

2 Answers2

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.

Community
  • 1
  • 1
qtuan
  • 687
  • 4
  • 10
1

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.

Mark Longair
  • 446,582
  • 72
  • 411
  • 327
  • thx,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 without files' changing,just set the HEAD and branch-B(usually dev branch) to the lastest commit,thx. – user392412 Sep 01 '11 at 17:55
  • I'm interested in doing it as a single operation that only touches the working directory once so that various file watchers I have going (like a big webpack recompile) get up-to-date more quickly. – Andy Feb 26 '17 at 23:37