创建新的存储库,并将所有“旧”存储库文件保存在新的存储库中

时间:2019-05-26 07:08:54

标签: git

我有一个已经接近2G限制的现有存储库。 我需要尝试进行第一次尝试来尽可能地缩小它,以使旧的已删除文件历史记录被删除,从而使存储库中有更多可用空间。

我想第一次尝试在要创建的新存储库中拥有的旧存储库副本上执行此操作。

由于我对GIT不太了解,而且我害怕损坏现有的存储库,因此我寻求您可以发送给我的任何帮助,以了解需要完成的所有设置实际上如何进行并带来副作用我将看到通过此过程将有多少可用空间。

我试图遵循以下指南:https://confluence.atlassian.com/bitbucket/reduce-repository-size-321848262.html,但我真的很害怕自己没有帮助。 再次感谢您的帮助。

我创建了“旧”存储库的副本,并将其备份到其他文件夹中。

1 个答案:

答案 0 :(得分:0)

您可以导出tarball并在那里初始化新存储库

cd old_repo #Wherever your git repository is
mkdir ../new_repo

#The following line copies over the files from your existing repository with 
#.git files and repository history etc

git archive master | tar -x -C ../new_repo 

cd ../new_repo

# Delete any files you want 

git init .
git add -A
git commit -a

# Create a new git repository on atlassian or github
git remote add origin <new_repo_url_from_atlassian_or_github>
git push -u origin master # or any other branch