Git - 重复提交问题 [英] Git - Duplicate commit issue

查看:174
本文介绍了Git - 重复提交问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我意外地在我的仓库中创建了未知提交,并决定尝试运行这里

  git filter-branch --commit-filter'
if [$ GIT_COMMITTER_NAME=未知];
然后
GIT_COMMITTER_NAME =..;
GIT_AUTHOR_NAME =..;
GIT_COMMITTER_EMAIL =...;
GIT_AUTHOR_EMAIL =...;
git commit-tree$ @;
else
git commit-tree$ @;
fi'HEAD

起初我认为一切都很好,直到我注意到gitk在运行之前的每一次提交都会被复制,而不是像我原先想象的那样简单地进行编辑。



是否可以清除它?



编辑:好了,gitk显示了旧提交(与未知commiters混合的提交)和新提交(重写的)指向中途。想想一堆提交,然后复制(并与编辑),并堆叠在原来的。我想要做的是如果可能的话,就是删除原来的文件。 解决方案

答案是 .git / refs / original ,以及我发现的命令不应该以 HEAD 结尾,而是使用 --tag-name-filter cat - --all



欢呼到_Vi并且是# git 频道寻求帮助。


I accidentally created commits by "unknown" in my repository, and decided to try running a command from here:

git filter-branch --commit-filter '
        if [ "$GIT_COMMITTER_NAME" = "unknown" ];
        then
                GIT_COMMITTER_NAME="..";
                GIT_AUTHOR_NAME="..";
                GIT_COMMITTER_EMAIL="...";
                GIT_AUTHOR_EMAIL="...";
                git commit-tree "$@";
        else
                git commit-tree "$@";
        fi' HEAD

At first I thought everything was fine, until I noticed in gitk that every commit prior to running this was duplicated, not simply edited as I originally thought.

Is it possible to clean this up?

EDIT: OK, gitk is showing both the old commits (the ones with the "unknown" commiters mixed in) and the new commits (the rewritten ones), split up at a certain point around halfway. Think a bunch of commits, then duplicated (and with the edits), and stacked on top of the original ones. What I want to do is if possible, is remove the original ones.

解决方案

The answer was the files in .git/refs/original, and how the command I found should not have ended in HEAD but instead with --tag-name-filter cat -- --all.

Cheers to _Vi and wereHamster from the #git channel for the help.

这篇关于Git - 重复提交问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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