git刪除遠程分支文件,不改變本地文件


git提交項目時候踩的Git的坑

特別

由於准備春招,所以希望各位看客方便的話,能去github上面幫我Star一下項目
https://github.com/Draymonders/Campus-Shop

經歷

由於剛開始沒有設置.gitignore文件,導致項目中所有的文件都被提交到了github上面,由此帶來的問題就是有些debug日志也被提交了上去,對於團隊開發很不友好。

一個錯誤的嘗試

git rm -r --cached "fileName/directionName"

執行這個,發現文件里面有.等特殊字符的就會報錯

fatal: pathspec '.settings/' did not match any files

最后的解決方案

沒辦法
只能把一些沒用的文件,暫時移動到回收站
然后分別執行

git add .
git commit -m "delete some files that others do not need"
git push -u origin master

如果還是有問題的話

git提供了很好的回滾機制,如果回滾到了遠程庫之前的版本,那么提交的時候 記得要-f參數

git log
git reset --hard b262ba9678b3aa4ed79e463b3a5e21398419eb56
git status
git add .
git commit -m "delete some files that others do not need"
git push -f origin master


免責聲明!

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



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