search

Home  >  Q&A  >  body text

There are too many changes that cannot be submitted to github. How do I clear the historical change records?

As mentioned, I haven’t pushed to github for half a year. Since there are several jars in it that have not been ignored, there are more and more. After pushing, it will report:

Counting objects: 4779, done.
Delta compression using up to 4 threads.
Compressing objects: 100% (3903/3903), done.
error: RPC failed; result=56, HTTP code = 200 | 14.92 MiB/s
fatal: The remote end hung up unexpectedlyMiB | 158.00 KiB/s
Writing objects: 100% (4779/4779), 628.84 MiB | 152.00 KiB/s, done.
Total 4779 (delta 2353), reused 3 (delta 0)
fatal: The remote end hung up unexpectedly
Everything up-to-date

I searched for some methods, such as changing to ssh, etc., but none of them worked. Is there any simple way to discard the history and only push the current version?

There is really no choice but to clone and overwrite again, but there are hundreds of megabytes online, so it would be best if there are any command parameters that can be simply discarded.


Find a way https://www.kernel.org/pub/software/scm/git/docs/git-filter-branch.html to clear the history. I am currently trying it. I will continue writing when it is OK.

某草草某草草2795 days ago653

reply all(2)I'll reply

  • 伊谢尔伦

    伊谢尔伦2017-05-02 09:33:58

    I finally found a simple way. Using the filter-branch command that comes with git can filter and delete, but it is too slow. I ran it all night and it didn't end, stuck at 98% progress. Later, I found the BFG Repo-Cleaner tool and deleted it within a few minutes. The size of the .git directory was reduced from about 2.9G to 70M. I deleted all tar.gz, zip, jar, war, etc. submitted in the past. Leave the source code behind and finally push it to github.

    The specific execution process is:

    bfg --delete-files *.tar.gz # 后面的文件名匹配可换成自己要删除的文件名
    git reflog expire --expire=now --all
    git gc --prune=now --aggressive
    git push --all --force
    git push --all --tags --force
    

    reply
    0
  • 大家讲道理

    大家讲道理2017-05-02 09:33:58

    Rebase, -f when pushing

    reply
    0
  • Cancelreply