5

Occasionally, my collaborators will "panic" when there is an automatic merge generated as the result a git-pull, and just accept the default commit message. Before this commit gets pushed, I want to be sure the message gets fixed, but --amend seems not to work. What is the best way to fix the message that's generated in this scenario. The best instructions I can come up with for them are

git reset --soft HEAD~
git merge -m <message> <the tracked remote branch>

but that seems a bit scary (reset) and error prone (the remote tracked branch has to be entered explicitly).

Is there a simple way to change the commit message that was just generated by merging with a remote tracking repo? Why doesn't --amend work?

orome
  • 45,163
  • 57
  • 202
  • 418
  • 2
    `git commit --amend` works for me in this scenario (git 1.7.9.5). What trouble are you having with it? FYI, you can use `@{u}` to refer to the tracked remote branch. – cmbuckley Jan 29 '13 at 00:45
  • @cbuckley: You're right! I [can't make this happen again](http://stackoverflow.com/a/14576413/656912) (git 1.8.1). – orome Jan 29 '13 at 19:04

3 Answers3

2

git commit --amend should work in this scenario. What exactly does not work?

Chronial
  • 66,706
  • 14
  • 93
  • 99
  • perfect – forgot to mention in my answer: `git commit --amend` is also the absolutely correct tool for a situation like this. – Chronial Jan 29 '13 at 20:58
-1

You can always try using git pull --rebase in order to put your commits on top of the tree. But git warns against this saying.

"This is a potentially dangerous mode of operation. It rewrites history, which does not bode well when you published that history already. Do not use this option unless you have read git-rebase(1) carefully." (http://git-scm.com/docs/git-pull)

If you are fine with eliminating the history of the merge then this is the option for you.

tetenal
  • 119
  • 1
  • 5
-1

@{u} is a good replacement for your <the tracked remote branch>, and then you can just glue the two steps into one. Perhaps a shell script you can distribute to them, or an alias they can add to their shells.

amalloy
  • 89,153
  • 8
  • 140
  • 205