1
有一次,我意外地用错误的作者电子邮件推送了一个提交到远程仓库。我用Git历史改写搞砸了分支
git filter-branch -f --env-filter "GIT_AUTHOR_NAME='Niklas Rosenstein'; GIT_AUTHOR_EMAIL='<<email>>'; GIT_COMMITTER_NAME='Niklas Rosenstein'; GIT_COMMITTER_EMAIL='<<email>>';" HEAD
重写历史。然后我用
$ git push origin development
Enter passphrase for key '----':
To [email protected]_cip:rosenstein/beak.git
! [rejected] development -> development (non-fast-forward)
error: failed to push some refs to '[email protected]_cip:rosenstein/beak.git'
hint: Updates were rejected because the tip of your current branch is behind
hint: its remote counterpart. Merge the remote changes (e.g. 'git pull')
hint: before pushing again.
hint: See the 'Note about fast-forwards' in 'git push --help' for details.
$ git pull origin development
Enter passphrase for key '----':
From gitlab_cip:rosenstein/beak
* branch development -> FETCH_HEAD
Merge made by the 'recursive' strategy.
$ git push origin development
Enter passphrase for key '----':
Counting objects: 430, done.
Delta compression using up to 2 threads.
Compressing objects: 100% (336/336), done.
Writing objects: 100% (402/402), 43.93 KiB | 0 bytes/s, done.
Total 402 (delta 262), reused 85 (delta 65)
To [email protected]_cip:rosenstein/beak.git
dd06969..2b2ddb4 development -> development
这可能是一个巨大的错误。
我得到了所有提交了一倍!错误的提交人的作者是固定的(完全重复,然后更改),但原始提交也存在!
我后来读了我(可能)应该使用
git push origin --force development fix
我可以以某种方式解决这一问题?
不是'HEAD〜1'而不是'HEAD^1'? –
非常感谢,它工作正常(用'HEAD〜1')! –
@NiklasR好的,我刚刚解释了一下为什么我最初用'^ 1'去了。 – VonC