3 回答

TA貢獻2037條經(jīng)驗 獲得超6個贊
這是蠻力的方法。它還會刪除存儲庫的配置。
注意:如果存儲庫有子模塊,這不起作用!如果您正在使用子模塊,則應使用例如交互式rebase
第1步:刪除所有歷史記錄(確保您有備份,這不能還原)
cat .git/config # note <github-uri>rm -rf .git
第2步:僅使用當前內(nèi)容重建Git倉庫
git initgit add .git commit -m "Initial commit"
第3步:推送到GitHub。
git remote add origin <github-uri>git push -u --force origin master

TA貢獻1865條經(jīng)驗 獲得超7個贊
唯一適合我的解決方案(并保持子模塊正常工作)是
git checkout --orphan newBranch
git add -A # Add all files and commit them
git commit
git branch -D master # Deletes the master branch
git branch -m master # Rename the current branch to master
git push -f origin master # Force push master branch to github
git gc --aggressive --prune=all # remove the old files
.git/當我有子模塊時,刪除總是會導致很大的問題。使用git rebase --root會以某種方式導致我的沖突(并且需要很長時間,因為我有很多歷史)。
- 3 回答
- 0 關(guān)注
- 643 瀏覽
添加回答
舉報