Commit to multiple branches at the same time

The cherry-pick feature will do the job and will only apply the last commit:

Considering branches A, B

git checkout A
git commit -m "Fixed the bug x"
git checkout B
git cherry-pick A

hope this helps!


Since there is no typical answer for my question, I have written a simple script to automate this process. Feel free to comment this code.

#!/bin/bash
BRANCHES=(
master_branch
develop_branch
testing_branch
)
ORIGINALBRANCH=`git status | head -n1 | cut -c13-`
git commit -m $1
CHERRYCOMMIT=`git log -n1 | head -n1 | cut -c8-`
for BRANCH in "${BRANCHES[@]}";
do
    git stash;
    git checkout $BRANCH;
    git cherry-pick $CHERRYCOMMIT;
    git checkout $ORIGINALBRANCH;
    git stash pop;
done