Automatically reword all rebased commits

前端 未结 1 876
情歌与酒
情歌与酒 2021-01-13 11:27

I want to be able to touch up my commit messages before I push them to my remote, but I want to automatically do that.

I can reword all my additional commits by doin

1条回答
  •  情话喂你
    2021-01-13 12:13

    Since the question is a bit vague on the nature of edits, these are just cues on what you could do.

    I don't want to have to change every commit to reword.

    You could change the editor used by git-rebase -i with git config sequence.editor 'sed -i s/pick/reword/', so that no editor pops for the rebase-todo, and picks are replaced. But that's a bit clumsy because you have to cancel the config after. (there's also core.editor for other cases, and $EDITOR).

    You can also run git rebase origin/master -x 'git commit --amend'. -x adds a exec , line after each pick in the rebase-todo. Note there's no -i needed here. The amend will allow you to change the commit message, for example git commit --amend -m "new message".

    I don't want to manually type in every commit I want to reword the message of.

    You can use the EDITOR variable to a non-interactive command that edits in the way you want, but I don't know which kind of editing you want to do.

    I want to rebase all the new commits with something other than pick

    See previous answers.

    0 讨论(0)
提交回复
热议问题