Github desktop amend commit9/5/2023 This is a more elaborated version of version: Note that if you already fixed the author information with git config user.name and git config user.email, you can also use this command: git rebase -i HEAD~N -x "git commit -amend -reset-author -no-edit" This gives you a nice middle ground between automation and control: you see the steps that will run, and once you save everything will be applied at once. You can then still modify some lines to see where you want to change the author. The file you edit will look like this: pick 897fe9e simplify code a littleĮxec git commit -amend -author 'Author Name ' -no-edit when you use git rebase -i, you can manually select the commits where to change the author,.the -no-edit flag makes sure the git commit -amend doesn't ask an extra confirmation.This can be a hash, HEAD~4, a branch name. replace HEAD~N with the reference until where you want to rewrite your commits.Proper Name Commit Name Īnd then run filter-repo with the created mailmap: git filter-repo -mailmap git-mailmapĪ single command to change the author for the last N commits: git rebase -i HEAD~N -x "git commit -amend -author 'Author Name ' -no-edit" ' -tag-name-filter cat -branches -tagsįor using alternative history filtering tool git filter-repo, you can first install it and construct a git-mailmap according to the format of gitmailmap. Git filter-branch -env-filter Correct Įxport GIT_COMMITTER_NAME="$CORRECT_NAME"Įxport GIT_COMMITTER_EMAIL="$CORRECT_EMAIL" Specifically, you can fix all the wrong author names and emails for all branches and tags with this command (source: GitHub help): #!/bin/sh see the "Environment Variables" section of the git manual page. Also note that you can use environment variables to change the name of the author, committer, dates, etc. The manual page includes several examples to get you started. If you're okay with that and think it's worth it then you should check out git filter-branch. If you still need to use git filter-branch, please carefully read SAFETY (and PERFORMANCE) to learn about the land mines of filter-branch, and then vigilantly avoid as many of the hazards listed there as reasonably possible.Ĭhanging the author (or committer) would require rewriting all of the history. Please use an alternative history filtering tool such as git filter-repo. These safety and performance issues cannot be backward compatibly fixed and as such, its use is not recommended. Git filter-branch has a plethora of pitfalls that can produce non-obvious manglings of the intended history rewrite (and can leave you with little time to investigate such problems since it has such abysmal performance). This answer uses git-filter-branch, for which the docs now give this warning: Note that -p has serious issues and is now deprecated. Just amend the commit: git commit -amend -no-edit -reset-authorĮntire project history git rebase -r -root -exec "git commit -amend -no-edit -reset-author" If you just want to change the most recent commit, a rebase is not necessary. Note that doing so will not update the committer - just the author. If you did not want to change that config, you can use -author "New Author Name " instead of -reset-author. This will change both the committer and the author to your user.name/ user.email configuration. If you also want to change your first commit (also called the 'root' commit), you will have to add -root to the rebase call. exec will run the git commit step after each commit is rewritten (as if you ran git commit & git rebase -continue repeatedly). exec 'git commit -amend -no-edit -reset-author' To rewrite metadata for a range of commits using a rebase, do git rebase -r \ This is optional, but it will also make sure to reset the committer name, too, assuming that's what you need. Using Rebaseįirst, if you haven't already done so, you will likely want to fix your name in git-config: git config -global user.name "New Author Name" If you only want to fix the spelling of a name or update an old email, Git lets you do this without rewriting history using. NOTE: This answer changes SHA1s, so take care when using it on a branch that has already been pushed.
0 Comments
Leave a Reply.AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |