12/24/2023 0 Comments Git commit amend author![]() ![]() Use specified mailmap file (see git-shortlog(1) for details on the format) when rewriting author, committer, and tagger names and emails. Then the script will be executed if you don’t interrupt it with ctrl+c. ![]() If you insist to use filter-branch command, run the script like below and wait a few seconds. usr/bin/env: ‘python3’: No such file or directory # If it prompts below error, change "python3" to "python" in the git-filter-repo file (expected at most one entry in the reflog for HEAD) Troubleshooting # If your repository are not a fresh cloned one, use -forceĪborting: Refusing to destructively overwrite repo history since Replace both the name and the email of a commit matching both the specified commit name and email address: Proper Name Commit Name Replace both the name and the email of a commit matching the specified commit email address: Proper Name Replace only the email part of a commit matching the specified commit email address: Replace name of a commit matching the specified commit email address: Proper Name ![]() The -mailmap option needs a mailmap file of format accepted by git shortlog. Here we name it as my-mailmap and put below content that specifies to replace both the name and the email of a commit matching the specified commit email address: john įinally, run filter-repo with the mailmap you created: $ git filter-repo -mailmap my-mailmap Then write a mailmap file in which you specify the name and/or email. Before you start, make your working directory clean.įirst download git-filter-repo command (it requires Python3) and put the git-filter-repo file to a location on the PATH. Here we use git-filter-repo command rather than filter-branch according the suggested way in above warning. Hit Ctrl-C before proceeding to abort, then use anĪlternative filtering tool such as 'git filter-repo'įilter-branch manual page for more details to squelch this warning,Ĭannot rewrite branches: You have unstaged changes. WARNING: git-filter-branch has a glut of gotchas generating mangled history If you run the script mentioned in GitHub: changing author info, the Git bash (v2.28.0) will give below warning: $. However there are issues with filter-branch, there have been some alternatives to replace this command such as git-filter-repo. In that guide it provides a script that use filter-branch command to rewrite the name and email if the commit email equals some value. To change the name and/or email of the entire history, of course filter-branch can do that as GitHub: changing author info mentioned. # Action: change "pick" to "edit" in the prompted script for commits Below is an example (for messy history, don’t use this method for inconsistent issue that may cause): # Change the last two commits. See Git book: rewrite history for more details. ![]() Then in the process you can use git commit -amend used above to do the change. To change the name and/or email of some specific existing commits, you can use rebase in an interactive mode which allows you to change the commit one by one. What git commit -amend does is replacing the tip of the current branch by creating a new commit., therefore it renew the commit date as well.Ĭhange author info of multiple existing commits $ git commit -amend -no-edit -reset-author $ git config user.email -reset-author, use the current user info. # Update the user info in configureation first, then amend the commit to $ git commit -amend -no-edit -author "john " # Use -author option to specify the new author and email. # Change the last commit to use new author and email. If you only want to change author info of the last commit, you can amend it to use new name and email. Because the other members may have did some work based on your commits. Take care to do that if you have pushed these commits to the remote server and there are other members who have access to that repository. In the post, you will learn how to do that. If you are not setting the author info correctly or just want to use another email to prevent it from being exposed, you may want to change the author name and/or email of the existing commits. ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |