git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Keep original author with git merge --squash?

From
David Glasser <glasser@davidglasser.net>
Date
Feb 11, 2015, 17:21 UTC
Message-ID
<CAN7QDoKQAZKUt_MHWjgt1k3PvXQv6XTcjdijh8KRodO3=VD47A@mail.gmail.com>

I frequently find myself using `git merge --squash` to combine a series of commits by the same author into one.

(For example, I fetch my project's GitHub PRs into my repo. Frequently, a PR consists of the original PR (with a good description) followed by a few follow-ups based on feedback from me. While I'd prefer that the submitter amended their original commit instead of making it my job, this is rare. And I don't feel that it's valuable to my project's git history to contain all the intermediate stages of code review --- it's usually just one commit.)

So `git merge --squash origin/pr/1234` is a really convenient command here... except for one thing: it sets the author as me. I always have to manually find the author line and make sure to pass it to --author (perhaps with --amend).

What would people think of a flag (or a config value) that means "if all merged commits are by the same author, use that author for the resulting commit instead of the default author"?

(I'm not sure if this should be a flag to --squash or to commit. Maybe `git merge --squash`; `git commit --use-squashed-author`? Seems like it should be not too hard to implement; SQUASH_MSG is pretty parseable. Or just a config value.)

--dave
-- 
glasser@davidglasser.net | langtonlabs.org | flickr.com/photos/glasser/
Next: Jeff King
Message 1 of 18 in “Keep original author with git merge --squash?”
  1. David GlasserFeb 11, 2015
  2. Jeff KingFeb 12, 2015
  3. Michael HaggertyFeb 12, 2015
  4. Jeff KingFeb 12, 2015
  5. David GlasserFeb 12, 2015
  6. Junio C HamanoFeb 12, 2015
  7. David GlasserFeb 12, 2015
  8. Junio C HamanoFeb 12, 2015
  9. David GlasserFeb 12, 2015
  10. David GlasserFeb 12, 2015
  11. Junio C HamanoFeb 12, 2015
  12. Jeff KingFeb 12, 2015
  13. Junio C HamanoFeb 12, 2015
  14. Jeff KingFeb 13, 2015
  15. Junio C HamanoFeb 13, 2015
  16. Jeff KingFeb 13, 2015
  17. David GlasserFeb 13, 2015
  18. David GlasserFeb 13, 2015

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.