I want to change the email of all of my repository's commits (safley without affecting anything else) so that my contribution graph on github is updated, can someone guide me on what I need to do? If it can be done via github or IntelliJ that would be preferable but will use git commands if necessary.
Asked
Active
Viewed 590 times
0
-
https://stackoverflow.com/search?q=%5Bgit%5D+change+email+all+commits – phd Apr 21 '22 at 10:02
1 Answers
1
You could use Git-filter-repo to change the commit history. They have really good documentation.

Madkoo
- 43
- 5
-
Note that the result of `git filter-repo` is a *new repository*, which may have commits that aren't related to the original repository. As such, it's a perfectly good answer, but it might "affect [something] else" in a shared repository on GitHub. In particular anyone who has a fork of the repository or is otherwise using it will need to adapt to the new repository. – torek Apr 21 '22 at 09:49
-
What do you mean by "new repository", its a tool meant to rewrite git history. It does not create a new repository for you. Think you are mixing things up here. The question was how to change his repository commits(history) email. And that is one of the tools that could be used. At this moment one of the best tools compared to others. Also it is recommended by the git project them selves: https://git-scm.com/docs/git-filter-branch#_warning – Madkoo Apr 21 '22 at 14:12
-
`git filter-repo` literally creates a new repository (using fast-export and fast-import). filter-branch does an in-place rewrite, but the result should be treated *as if* it is a new repository. See also items 4 and 6 in the description of using filter-repo. – torek Apr 21 '22 at 14:18
-
See `git filter-repo` [DISCUSSION](https://htmlpreview.github.io/?https://github.com/newren/git-filter-repo/blob/docs/html/git-filter-repo.html#DISCUSSION) section for important details before running this command. – John Pancoast Sep 18 '22 at 07:27
-
@torek, I think you might be talking about [git filter-repo's internals](https://htmlpreview.github.io/?https://github.com/newren/git-filter-repo/blob/docs/html/git-filter-repo.html#INTERNALS) whereas @Madkoo is just saying that this tool rewrites history on the existing repo (i.e., same `.git` dir in the end).So you're both right. Either way, command still has dangerous implications on shared repos so people should see command's [DISCUSSION](https://htmlpreview.github.io/?https://github.com/newren/git-filter-repo/blob/docs/html/git-filter-repo.html#DISCUSSION) section. – John Pancoast Sep 18 '22 at 07:29
-
@JohnPancoast: it's not just the internals: filter-repo explicitly creates a separate new repository (on purpose, to avoid the confusion people got with the old filter-branch). That is, one sees the effect externally. You're correct of course that it's possible to rejoin the new history with the old history; this is exactly where things keep going wrong with the old filter-branch, which is why filter-repo generates a new repository! – torek Sep 18 '22 at 07:34
-
@torek, I think we may be misunderstanding each other and I'm not sure where. Yes, `git filter-repo` was made to improve upon the problems of `git filter-branch`. `git filter-repo` does have extra checks to see if it's working on a clone, in which case it warns the user to use a clone or use `--force` option. But my point is that the command still operates on the repo you specify by default and it doesn't create a new repo. Perhaps it's that's terminology that's confusing. Please see [this gist](https://gist.github.com/johnpancoast/df322533acbb775b7e169768da62536e) that explains what I mean. – John Pancoast Sep 20 '22 at 08:01
-
@torek It's possible you're just referring to the fact that `git filter-repo` does extra checks to make sure it's working on a cloned repo (among other things it checks) and if it's not a cloned repo it suggests you work on a clone instead. If that's what you meant, you're totally right. I just don't believe the command itself is creating a new repo unless there's something I'm missing (totally possible with my brain) – John Pancoast Sep 20 '22 at 08:25
-
I had the impression that filter-repo actually ran its own `git init` and shuffled object and ref directories around for its `git fast-import` step, but maybe it doesn't do that. It does indeed insist on a "fresh" clone. I haven't delved any further into its internals though. – torek Sep 20 '22 at 09:28
-
@torek. Ahh I see where you're coming from. Yeah, that check on if you're running the command on a clone is one of the many nice features of `git filter-repo` vs. `git filter-branch`. Although it doesn't quite _insist_ you run it on a clone, it just highly suggests it. You can get around that behavior with the `--force` option like I did in my [gist](https://gist.github.com/johnpancoast/df322533acbb775b7e169768da62536e#file-git-filter-repo-example-sh-L23-L31) although I **would not** suggest anyone do that without knowing what they're doing. Apologies if I'm being unnecessarily pedantic. – John Pancoast Sep 24 '22 at 21:56