问题描述
我最近在GitHub上开了一个回购。我是Git的新手。和往常一样,我使用默认名称和电子邮件,这是我最好的小白传统,发现了五次提交太迟。现在乐趣开始了,因为我开始搜索如何改变作者&这些提交的提交者名称。精细。我基本上找到了以下信息和许多副本:
这个问题似乎并不罕见。我只能说没有任何解决方案奏效。其中一半是相同的 git filter-branch -f --env-filter
脚本的变体。我试图多次处理该脚本。问题是,在应用脚本后,我无法推送。 快进推送拒绝或类似的东西。好,唯一的办法就是拉。拉出后,所有旧信息再次出现+新信息的新分支。我已经坐在这里有四个分支,以最令人震惊的方式合并,所有这些分支都包含与不同作者姓名相同的信息,包括我想删除的信息。
确定要简化它,我也尝试删除选定的提交,这会产生我无法解决的毛病冲突(如何?),并且使用正确的作者信息压缩一些提交到新的提交,导致当前的项目状态被破坏。更好的是,在执行 git rebase -i
之后,我有时会遇到分段错误,我在这里通知:是完全合乎逻辑的。唯一(幸运的是)工作是 git rebase --abort
,它多次保存了我的屁股。
我希望我的挫败感不会排斥,而是会让你感到愉快,并激励你去帮助我。我想:
-
最后删除作者信息
但是我也会对第一个感到满意,如果删除过去的分支而不破坏当前的障碍状态对于git新手来说太多了。提前致谢。
如果您尝试修改历史记录,则无法避免此问题。 Git拒绝推送,因为它会导致数据丢失;在这种情况下,数据是旧的作者。你只需要 git push
与 - force
标志来告诉它你确定你在做什么做。
Git中的消息可能是一个需要解决的问题。如果 master
是一团乱麻,我通常只需回过头来看看 git checkout HEAD〜
,直到我回到一个事情并不可怕的时代。然后,我将 git branch --force master
重置为 master
到那一点。最后,我用 git branch -D badBranch
来删除所有乱七八糟的分支。 小心。
I recently opened a repo on GitHub. I'm new to Git. As usual with newcomers, I committed using the default name and email, which I, in the best noob tradition, discovered five commits too late. Now the fun starts, cause I started to search for info on how to change the author & committer name of these commits. Fine. I basically found the following info and a lot of copies:
How to remove selected commit log entries from a Git repository while keeping their changes?
Change the author and committer name and e-mail of multiple commits in Git
The problem does not seem to be uncommon. I can only say that none of the solutions worked. Half of them are variations of the same git filter-branch -f --env-filter
script. I tried to work on that script multiple times. The problem is that after applying the script, I cannot push. "Fast-forward pushes rejected" or something like that. Fine, the only way to go on is to pull. After pulling, all the old info is there again + a new branch with the new info. I'm already sitting here with four branches, merged in the most egregious ways, all containing the same info with different author names, including the one I wanted to delete.
OK to cut it short, I also tried to delete selected commits, which generates hair-raising conflicts that I am unable to resolve (how???), and to squash some of the commits into newer ones with the correct author information, which results in the current project state being wrecked. Even better, I get a segmentation fault sometimes after executing git rebase -i
, which I'm informed here: http://lists-archives.org/git/729800-rebase-i-segmentation-fault-and-another-problem.html is completely logical. The only thing that (thankfully) works is git rebase --abort
, which saved my ass multiple times.
I hope my frustration does not repel, but instead amuse you and stimulate you to help me. I'd like:
To remove said author info finally
Bonus: To get rid of all the branches containing the same information.
But I'd be happy with the first one too, if the hurdle of deleting past branches without wrecking the current state is too much for a git newcomer. Thanks in advance.
This problem cannot be avoided if you're trying to modify the history. Git's rejecting the push because it causes data to be lost; in this case that data is the old authors. You just need to git push
with the --force
flag to tell it you're sure of what you're doing.
Messes in Git can be a pain to resolve. If master
is a mess, I usually just move back through the history with git checkout HEAD~
until I get back to a time when things weren't terrible. I then git branch --force master
to reset master
to that point. Finally I delete all of the messy branches with git branch -D badBranch
.
Be careful.
这篇关于更改以前提交的作者姓名:快进推送拒绝的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!