github:你将如何删除某个用户名的所有提交 [英] github: How would you delete all commits by a certain username

查看:642
本文介绍了github:你将如何删除某个用户名的所有提交的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我第一次开始使用这个回购协议时,我之前没有使用过git,并且通过误用我的电子邮件或其他东西来阻止设置,所以一段时间所有的提交都是由用户未知提出的。我在这里找到了一个答案,将所有未知提交转换为我的名字,但实际上做了什么是重复提交并应用我的名字。所以现在我已经分散了所有这些未知用户提交。



所以我想知道一些命令可以运行删除未知用户的所有提交。 >

解决方案

您必须使用 git filter-branch )和强制推送到github。



手册中的示例处理几乎相同的情况,您想要从特定用户中删除提交:



如果[$ GIT_AUTHOR_NAME=Darl McBribe];
然后
skip_commit$ @;
else
git commit-tree$ @;
fi'HEAD

请注意,这会重写您的历史记录,并且可能会影响其他人使用您对协作者的repo.Github建议:


处理协作者



您可能会有合作者将你的受污染的分支拉下来,并在其上创建
自己的分支。在他们获取新分支后,他们
将需要在他们自己的分支上使用git rebase来重新绑定新分支
。协作还应确保其分支
不会重新引入该文件,因为这将覆盖.gitignore
文件。确保你的协作使用rebase而不是合并,否则他
将只是重新引入文件和整个受污染的历史......而
可能会遇到一些合并冲突。


http://help.github.com/remove-sensitive-data/


When I first started out with this repo, I hadn't used git before and biffed the setup by mistyping my email or something so all commits for a while were made by the user "unknown." I found an answer on here to convert all the "unknown" commits to my name but what it actually did was duplicate the commit and apply my name. So now I have all these "unknown" user commits scattered.

So I was wondering about some commands to run to delete all commits by "unknown" user.

解决方案

You will have to make use of git filter-branch (in your repo ) and force push to github.

Example from manual that deals almost the same situation where you want to remove commits from a particular user:

git filter-branch --commit-filter '
    if [ "$GIT_AUTHOR_NAME" = "Darl McBribe" ];
    then
            skip_commit "$@";
    else
            git commit-tree "$@";
    fi' HEAD

Note that this will rewrite your history and it might affect others who also use your repo.Github advice on collaborators:

Dealing with collaborators

You may have collaborators that pulled your tainted branch and created their own branches off of it. After they fetch your new branch, they will need to use git rebase on their own branches to rebase them on top of the new one. The collab should also ensure that their branch doesn’t reintroduce the file, as this will override the .gitignore file. Make sure your collab uses rebase and not merge, otherwise he will just reintroduce the file and the entire tainted history… and likely encounter some merge conflicts.

http://help.github.com/remove-sensitive-data/

这篇关于github:你将如何删除某个用户名的所有提交的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆