清除Git倉庫多余文件及其歷史記錄 


清除Git倉庫多余文件及其歷史記錄 

轉自:https://www.cnblogs.com/msxh/p/11082246.html

 

  1.切換到新的分支

git checkout --orphan latest_branch

  2.緩存所有文件(除了.gitignore中聲明排除的)

 git add -A

  3.提交跟蹤過的文件(Commit the changes)

 git commit -am "commit message"

  4.刪除master分支(Delete the branch)

git branch -D master

  5.重命名當前分支為master(Rename the current branch to master)

 git branch -m master

  6.提交到遠程master分支 (Finally, force update your repository)

 git push -f origin master

  通過以上幾步就可以簡單地把一個Git倉庫的歷史提交記錄清除掉了,不過最好還是在平時的開發中嚴格要求一下提交日志的規范,盡量避免在里面輸入一些敏感信息進來。

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM