# Merge local branch foo into local branch master,# without having to checkout master first.# Here `.` means to use the local repository as the "remote":git fetch . foo:master
# Merge remote branch origin/foo into local branch foo,# without having to checkout foo first:git fetch origin foo:foo
# Check if you can fast-forwardif git merge-base --is-ancestor a b; thengit update-ref refs/heads/a refs/heads/bexitfi
# Else, create a "merge" commitcommit="$(git commit-tree -p a -p b -m "merge b into a" "$(git show -s --pretty=format:%T b)")"# And update the branch to point to that commitgit update-ref refs/heads/a "$commit"