Git script that fast forward merges and deletes the old branch This script fast forward merges a branch and then deletes the old one.  I normally run it like this:


git m master feature



Here's a link to the gist.

#!/bin/bash -x
set -e

#by naming this git-m and putting it in your PATH, git will be able to run it when you type "git m ..."

if [ "$#" -ne 2 ]
then
  echo "Wrong number of arguments. Should be 2, was $#";
  exit 1;
fi

git checkout $1;
git merge --ff-only $2;
git branch -d $2;


Is there anything wrong with this?  My biggest fear is I could run this script with a typo and end up deleting a branch without merging first.
The order of the arguments is backwards, I think. Compare against git-rebase(1):


  Synopsis
  
  git rebase [&lt;upstream&gt;] [&lt;branch&gt;]
  
  Description
  
  If &lt;branch&gt; is specified, git rebase will perform an automatic git checkout &lt;branch&gt; before doing anything else. Otherwise it remains on the current branch.


The git-rebase order is also better since the git checkout can be considered optional.  You should probably make yours optional as well.

The help message needs to be much more informative about what the command does and how to use it. Git is hard enough to use as it is.

Accidental branch deletion is unlikely to be tragic, since you used -d and not -D.