0

I changed the author name of some past commits (commits I made) using rebase starting at the root.

I used git rebase -i -p --root, and then marked the commits I wanted to change with "edit".

Then I used git commit --amend --author="Username <email>" --no-edit and then git rebase --continue for each commit.

It worked perfectly for the ones I marked edit, however, I am not the only one working in the repository. All the commits that I did not mark edit (ones that were not mine) now say that someone else authored but I committed. I reset the repository to before the rebase, but would like to know if there's a way to rebase without making it seeming like I committed everything? There must be a way to leave some commits alone during a rebase, but I can't find anything online.

knittl
  • 246,190
  • 53
  • 318
  • 364
  • 5
    Welcome to SO! You can use `GIT_COMMITTER_NAME` and `GIT_COMMITTER_EMAIL` environment variables to set it... _per revision_... but it won't hold water on a rebase. What's wrong with you being the committer? After all, you are **indeed** the committer on that rewritten history. – eftshift0 May 26 '21 at 00:06
  • 4
    If you need to do this kind of history rewriting, do it with a different tool (i.e., not with `git rebase`). Tools that do this include `git filter-branch` and its new replacement, `git filter-repo`. – torek May 26 '21 at 00:23
  • @torek would these not also change the committer details? – msbit May 26 '21 at 00:47
  • 1
    @msbit: no, these tools preserve all the metadata they can, except for anything you ask to be changed. (Filter-branch has historically had a few minor bugs here, while filter-repo uses Python and hence never had those particular minor bugs. Neither can preserve GPG signatures but both can preserve author and committer lines exactly.) – torek May 26 '21 at 01:06
  • @eftshift0 Thanks yes, first time asking something. I like your answer - I guess it does make sense that I'd commit the new history, but I'm set as the committer for commits I didn't even edit, or set to edit in the rebase. How can I leave those alone? Is "pick" the wrong word for them? – Coder Cow May 26 '21 at 03:19
  • @torek That sounds more like what I'm looking for, thanks. I'll try to figured out the command. – Coder Cow May 26 '21 at 03:20
  • "[…] but would like to know if there's a way to rebase without making it seeming like I committed everything?" Why "seeming like you committed"? You did in fact commit those commits. Rebasing creates new commits. So those were committed by you yourself. Anything else would be lying :-p – knittl Oct 19 '22 at 21:20

0 Answers0