title: Git: is it possible to edit the commit message using the pre-push hook?
body: <p>Before users push their commits, I'd like to pre-pend the branch name to the commit message.  Is this possible?</p>
  <p>If it is, would I use the <code>git commit --amend</code> command?</p>
  <p>Our branch names contain the ticket number and its important to see this info when its merged into master and in Jenkins.  To see it easily, it must be the first line in the commit message.  To ensure the fist line is the branch name (containing the ticket number), I'd like to use the pre-push hook.  I could use other hooks, such as <code>prepare-commit-message</code> or use a message template but that puts the branch name on every commit, and it doesn't ensure that the branch name is there after a rebase.   Using the pre-push ensures the branch name is there before it goes into the remote.</p>
  <p>=============</p>
  <h3>update:  Yes, it is possible but its a bad idea.</h3>
  <p>The pre-push hook syncs the refs with the remote <strong>before</strong> running but before any objects are pushed.  This means the remote already has the commit sha set for the change you are pushing.  When the <code>pre-push</code> hook ammends the commit message a new sha is generated, putting you immediately out of sync with the remote.</p>