[英]Can't remove file from git commit
如何丟棄所有未被推送的git提交然后強制git不在數據/目錄中提交任何內容?
我試圖從我的c9.io項目強制覆蓋存儲在github上的項目的所有更改。 我不小心git添加了一些mongodb數據文件。 我試圖將數據/目錄添加到.gitignore。 我從github撤出以獲取更新的.gitignore,但是當我嘗試git push時,這些數據/中的頑固文件仍然會進行提交。 我還試圖GIT中復位,GIT中底墊,GIT中清潔和這其中我改變dmpfile.sql到pi /數據/節點login.1。
請幫助我已經在這幾個小時,我真的很沮喪
Counting objects: 15, done.
Delta compression using up to 2 threads.
Compressing objects: 100% (13/13), done.
Writing objects: 100% (13/13), 150.22 KiB | 92 KiB/s, done.
Total 13 (delta 6), reused 0 (delta 0)
remote: warning: File pi/data/local.0 is 64.00 MB; this is larger than GitHub's recommended maximum file size of 50 MB
remote: warning: File pi/data/node-login.0 is 64.00 MB; this is larger than GitHub's recommended maximum file size of 50 MB
remote: error: GH001: Large files detected.
remote: error: Trace: e6ade98208c08b634ed28aefea36dfbb
remote: error: See http://git.io/iEPt8g for more information.
remote: error: File pi/data/node-login.1 is 128.00 MB; this exceeds GitHub's file size limit of 100 MB
To git@github.com:bobbyg603/goddard.git
! [remote rejected] master -> master (pre-receive hook declined)
error: failed to push some refs to 'git@github.com:bobbyg603/goddard.git'
的.gitignore:
lib-cov
*.seed
*.log
*.csv
*.dat
*.out
*.pid
*.gz
data/
pids
logs
results
npm-debug.log
node_modules
.project
.settings
謝謝,鮑比
感謝Chris我能夠通過運行以下內容來解決這個問題:
git filter-branch -f --index-filter'git rm --cached --ignore-unmatch pi / data / node-login.0'
git filter-branch -f --index-filter'git rm --cached --ignore-unmatch pi / data / node-login.1'
git filter-branch -f --index-filter'git rm --cached --ignore-unmatch pi / data / local.0'
git filter-branch -f --index-filter "git rm -rf --cached --ignore-unmatch FOLDERNAME" -- --all
將FOLDERNAME替換為您要從給定git存儲庫中刪除的文件或文件夾。
這對我有用:
git rm --cached name_of_a_giant_file
git rm --cached name_of_another_giant_file
git commit --amend -CHEAD
git push
來源: Github幫助:使用大文件
我使用BFG Repo Cleanner簡單而快速,就像一個魅力
git filter-branch --tree-filter 'rm -rf path/whaever' HEAD
這有點簡單,它是一種從歷史中刪除和重寫它的方法。 結果就是這樣
Rewrite 5ac3045254d33fc5bb2b9fb05dccbdbb986b1885 (61/62) (24 seconds passed, remaining 0 predicted)
Ref 'refs/heads/features_X' was rewritten
現在,我可以推動
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.