1. 程式人生 > >Git之刪除遠端倉庫上的檔案

Git之刪除遠端倉庫上的檔案

報錯解決:

$ git push origin master
To http://stash.lab.tclclouds.com/scm/sec/cloud_music_config_admin.git
! [rejected] master -> master (fetch first)
error: failed to push some refs to ‘http://[email protected]/scm/sec/cloud_music_config_admin.git
hint: Updates were rejected because the remote contains work that you do
hint: not have locally. This is usually caused by another repository pushing
hint: to the same ref. You may want to first integrate the remote changes
hint: (e.g., ‘git pull …’) before pushing again.
hint: See the ‘Note about fast-forwards’ in ‘git push –help’ for details.

解決:$ git push -f origin master

Password for ‘http://[email protected]‘:
To http://[email protected]
! [rejected] master -> master (fetch first)
error: 無法推送一些引用到 ‘http://[email protected]/scm/sec/cloud_music_config_admin.git
提示:更新被拒絕,因為遠端倉庫包含您本地尚不存在的提交。這通常是因為另外
提示:一個倉庫已向該引用進行了推送。再次推送前,您可能需要先整合遠端變更
提示:(如 ‘git pull …’)。
提示:詳見 ‘git push –help’ 中的 ‘Note about fast-forwards’ 小節。

解決:git pull origin master

初始化本地倉庫:

$ git config –global user.name “username”
$ git config –global user.email “[email protected]
$ git init
$ git add .
$ git commit -m ‘後臺程式碼’
$ git remote add origin http://[email protected]
$ git push origin master

刪除遠端倉庫上的檔案直接上命令:

git rm – cached react-app/.idea #刪除層級為第二層的資料夾
fatal: 未提供 -r 選項不會遞迴刪除 ‘react-app-scaffold/.idea’
git rm -r –cached react-app/.idea
git commit -m ‘將誤上傳的idea資料夾刪除’
git push origin master