M
M
mr_idiot2012-05-01 12:58:05
git
mr_idiot, 2012-05-01 12:58:05

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


As a result of all the old commits, there were two each: with the old nickname and the new one. Can I somehow fix it?

Answer the question

In order to leave comments, you need to log in

3 answer(s)
M
mr_idiot, 2012-05-01
@mr_idiot

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

S
SergeiStartsev, 2012-05-01
@SergeiStartsev

There was a similar problem on stackoverflow .

G
grossws, 2012-05-01
@grossws

What does he say git branch -a -v?

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question