I work on a project that has 2 branches, A and B. I typically work on branch A, and merge stuff from branch B. For the merging, I would typically do:
git mer
If you want to keep the same tree as one of the branch you want to merge (ie. not a real "merge"), you can do it like this.
# Check if you can fast-forward
if git merge-base --is-ancestor a b; then
git update-ref refs/heads/a refs/heads/b
exit
fi
# Else, create a "merge" commit
commit="$(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 commit
git update-ref refs/heads/a "$commit"