这是我继承的Rails应用程序中目录的相应大小:
→ find . -maxdepth 1 -type d -mindepth 1 -exec du -hs {} ;
263M ./.git
2.0M ./app
124K ./config
728K ./db
4.0K ./doc
56K ./lib
0B ./log
232K ./public
8.0K ./script
164K ./spec
560K ./spreadsheets
16K ./test
64K ./vendor
我从 Github 上的现有存储库分支创建了一个新存储库,并保留了旧存储库。 我不需要新存储库中的任何历史记录,因为旧存储库的特定分支成为新存储库的主节点,并且是新存储库中的唯一分支。 我想将 .git 的大小提高到最小大小,因为它在 Github 空间、本地空间和 Heroku 部署方面绝对是浪费。
Git init 不起作用。 我不知道我是否可以
rm -rf .git
然后重新初始化 git 存储库,然后将其推送到 Github 远程。
为了压缩 .git 目录,只保留某些分支删除旧提交。
请执行以下步骤:
- 删除不需要的分支
- 在您需要的提交之前修改提交
- 执行垃圾回收
执行以下命令:
# remove old content
rm -rf .git
# init new repo
git init
# add all current files (add .gitignore entries if you need to ignore some files)
git add -A .
# commit the current content
git commit - m ".. Message..."
# add the remote url of the github server
git remote add origin <github new url>
# oush your code to github
git push origin master