一、刪除GitHub遠程倉庫中的相關文件夾
在上傳項目到github時,忘記忽略了某個文件夾,就直接push上去了, 最後意識到了此問題,決定刪除掉遠程倉庫中的不需要的文件夾
1、刪除.idea 文件夾
shell>git rm -r --cached .idea #--cached不會把本地的.idea刪除
shell>git commit -m 'delete .idea dir'
shell>git push -u origin master #將本次更改更新到github項目上去 # 將本次更改更新到github項目上去
2、本地倉庫和遠程倉庫同時刪除
先在本地把兩個文件刪除,然後執行以下命令
shell>git add * //把本地倉庫的文件上傳到緩存。
shell>git commit -m 'del' //把第一步上傳到緩存的東西上傳到本地倉庫
shell> git push origin master //把本地倉庫的文件上傳到遠程倉庫。
二、撤銷commit
1、在github中如果不小心commit了,該如何撤銷
輸入 git log
shell>git log
我們發現,已經commit的6次了,我們通過命令回到 15721ca39aca1cbf64585ddb700868e77c534d9a(commit的hash值)
輸入回退命令
git reset --hard (+上面讓你複製的commit hash值)
shell>git reset --hard 15721ca39aca1cbf64585ddb700868e77c534d9a
2、使用IDEA撤銷
在Vserion Control裏的Log下,找到你要撤銷的commit,選中右鍵,點擊Undo commit...