将-mirror推入Git存储库时出现重复文件错误

时间:2015-09-15 04:53:15

标签: linux git github

我需要将现有的存储库推送到Git中的另一个空存储库。我收到以下错误:

remote: unpack error Invalid tree 300894f515: duplicate entry names
error: unpack failed: error Invalid tree 300894f515: duplicate entry names

在尝试了几个选项后,我能够重写历史记录并最终推送主分支。但是当我试图再次推动--mirror时,它显示的是同样的错误。我在这里附上日志。

  1. git clone URL
  2. git branch -a

    * master
    remotes/origin/HEAD -> origin/master
    remotes/origin/MyTestBranch
    remotes/origin/ABC
    remotes/origin/XYZ
    remotes/origin/TEST
    
  3. git remote add test REMOTE URL

  4. git remote -v

    origin  git@github.................. (fetch)
    origin  git@github................... (push)
    test    https://abc........................................... (fetch)
    test    https://abc........................................... (push)
    
  5. git fsck --full

    error in tree 300894f515b714a42efd603f4196d45c8c1f3c09: contains duplicate file entries
    error in tree a84c6e1cc242cdc4c7d7ce5246be02672d1eaf3a: contains duplicate file entries
    
  6. git filter-branch --index-filter 'mv "$GIT_INDEX_FILE" "$GIT_INDEX_FILE.tmp" && GIT_INDEX_FILE=$GIT_INDEX_FILE.tmp git ls-files -s | git update-index --index-info'

  7. git push test master

    Counting objects: 33396, done.
    Delta compression using up to 2 threads.
    Compressing objects: 100% (10456/10456), done.
    Writing objects: 100% (33396/33396), 86.61 MiB | 16.05 MiB/s, done.
    Total 33396 (delta 17522), reused 31573 (delta 17001)
    remote: Resolving deltas: 100% (17522/17522)
    remote: Counting objects: 33396, done
    remote: Updating references: 100% (1/1)
    To https://abc.................................................................git
    * [new branch]      master -> master
    
  8. git push --mirror test

    Counting objects: 35959, done.
    Delta compression using up to 2 threads.
    Compressing objects: 100% (11059/11059), done.
    Writing objects: 100% (35631/35631), 86.91 MiB | 16.52 MiB/s, done.
    Total 35631 (delta 19237), reused 35489 (delta 19127)
    remote: unpack error Invalid tree 300894f515: duplicate entry names
    error: unpack failed: error Invalid tree 300894f515: duplicate entry names
    
  9. 如何解决此问题?

2 个答案:

答案 0 :(得分:1)

我通过下面提到的步骤解决了这个问题。

  1. 起初我做了一个--mirror clone。
  2. 然后执行“git filter-branch -f --index-filter'git rm -rf --cached --ignore-unmatch SampleApp && git ls-files -s | git update-index --index-info' - prune-empty --tag-name-filter cat - --all“
  3. 然后我做了一个--mirror push。
  4. 此处SampleApp是已损坏的文件。

答案 1 :(得分:0)

您的重写历史记录位于cordova run android(即refs/heads/master分支)。但master将在filter-branch中创建已损坏历史记录的备份。你的refs/original/refs/heads/master推送会发送,导致对方抱怨。

您可能想要--mirror