Reputation: 1324
I am trying to change the author name and email on a Git repository however, I have followed several steps and yet I cannot see the changes reflected on my Github repository.
I ran the following script:
git filter-branch -f --env-filter "
GIT_AUTHOR_NAME='newname'
GIT_AUTHOR_EMAIL='newemail'
GIT_COMMITTER_NAME='newname'
GIT_COMMITTER_EMAIL='newemail'
" HEAD
I can see that it changes some commits but I have another remove set on the git and I am using Github extension to commit to my Github repository.
I have another remote set for Heroku, how can I change the commit author and email on my own repository?
Upvotes: 1
Views: 371
Reputation: 2165
I think there are only 2 commands for changing the history of the username and email of commits.
git rebase -i HEAD~N -x "git commit --amend --author 'new name <newemail>' --no-edit"
=> Where N = number of commits from latest to previous orders
git push origin branch_name
=> branch_name = branch of your repository like main, development etc...
Upvotes: 0
Reputation: 520878
When you ran filter-branch
, you did so on your local branches, not the remote ones. In fact, you have rewritten the history of all local branches, and, as a result, you will have to force push all local branches. Here is one way to do that:
git push --force --all
Keep in mind that rewriting the histories of remote branches which might be shared by other users on your team can reek havoc on those users when the next they pull. So, force push sparingly, and only when you really need to.
Upvotes: 1