如何删除 Git 存储库并推送新的
How to Remove Git repository and push new one
如何清除存储库并推送新的存储库。
我有大小超过 2GB 的项目,我检查了 .git
文件夹,它的大小是 1.5GB,我尝试删除 .git
文件夹,然后我做了 git init
并强制推送项目,但远程存储库大小未更改,我的步骤:
git init
git add .
git commit -m "First Push"
git remote add origin http://Url_here
git push -f origin master
如何替换存储库内容?
见Force "git push" to overwrite remote files
我认为你正在将 origin master 添加到你的推力中,所以你没有覆盖所有内容...
git push -f
但这将替换存储库中的所有内容....
几个选项:
转到服务器存储库,删除旧存储库并创建一个新存储库。
在当前 repo 中推送新分支
创建一个新的 orphan
分支然后推送它。
现在在你的服务器上 运行 git gc --aggressive --prune=now
清除所有旧提交
使用filter branch
清除所有旧内容
使用rebase -i
并将所有提交压缩为一个然后推送它
使用 git subtree' split to create a new project from the existing code.Similar to
git filter-tree`,使用正确的代码会产生相同的结果。
以 root 身份登录删除 .git
sudo rm -R .git
以正确的用户身份登录
git init
git remote add origin https://[name]@bitbucket.org/frankdesign/[new-repo].git
git add .
git commit -m "new clean repo"
git push --force origin master
如何清除存储库并推送新的存储库。
我有大小超过 2GB 的项目,我检查了 .git
文件夹,它的大小是 1.5GB,我尝试删除 .git
文件夹,然后我做了 git init
并强制推送项目,但远程存储库大小未更改,我的步骤:
git init
git add .
git commit -m "First Push"
git remote add origin http://Url_here
git push -f origin master
如何替换存储库内容?
见Force "git push" to overwrite remote files
我认为你正在将 origin master 添加到你的推力中,所以你没有覆盖所有内容...
git push -f
但这将替换存储库中的所有内容....
几个选项:
转到服务器存储库,删除旧存储库并创建一个新存储库。
在当前 repo 中推送新分支创建一个新的
orphan
分支然后推送它。
现在在你的服务器上 运行git gc --aggressive --prune=now
清除所有旧提交使用
filter branch
清除所有旧内容使用
rebase -i
并将所有提交压缩为一个然后推送它使用
git subtree' split to create a new project from the existing code.Similar to
git filter-tree`,使用正确的代码会产生相同的结果。
以 root 身份登录删除 .git
sudo rm -R .git
以正确的用户身份登录
git init
git remote add origin https://[name]@bitbucket.org/frankdesign/[new-repo].git
git add .
git commit -m "new clean repo"
git push --force origin master