Answer the question
In order to leave comments, you need to log in
Why were all the commits duplicated?
Wanted to fix my early commits in the repository with the wrong username and email.
Found this script:
#!/bin/bash
git filter-branch --commit-filter '
if [ "$GIT_COMMITTER_NAME" = "<старый ник>" ];
then
GIT_COMMITTER_NAME="<новый ник>";
GIT_AUTHOR_NAME="<новый ник>";
GIT_COMMITTER_EMAIL="<новая почта>";
GIT_AUTHOR_EMAIL="<новая почта>";
git commit-tree "[email protected]";
else
git commit-tree "[email protected]";
fi' HEAD
Answer the question
In order to leave comments, you need to log in
I dug around and figured out what my mistake was. I ran the rename script while on a branch (not master). Accordingly, git drew a new commit history, and when it merged the branch into master, added it to the original one.
There is no easy way to fix this, but you can do the following: roll back the master branch to the commit before the merge:
The history is still normal there. Then cherry-pick all desired feature branch commits:
You can cherry-pick to a new branch and then merge it into master to restore the merge commit.
And you need to rewrite history from the master branch. And after that, old branches cannot be poured into it.
git reset --hard commit
git cherry-pick commit..commit
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question