2016-06-11 72 views
-1

在無意中添加了一個我不想要的大文件並且在無意中添加大文件後做了其他工作的額外提交(不知道推送失敗)之後,我處於與此處所述相同的情況:如何從GitHub存儲庫中刪除大(> 100MB)文件並推送成功?

Am I supposed to run BFG on the mirrored repo or the original?


未遂#1 試過這種刪除該文件:

git rm bigfile 
git commit bigfile 
git push 

沒有運氣。推仍然停留在試圖上傳大文件,即使後來提交刪除它:

$混帳推

Username for 'https://github.com': 
Password for 'https://[email protected]': 
Counting objects: 210, done. 
Delta compression using up to 4 threads. 
Compressing objects: 100% (66/66), done. 
Writing objects: 100% (210/210), 5.72 MiB | 1.47 MiB/s, done. 
Total 210 (delta 147), reused 203 (delta 140) 
remote: error: GH001: Large files detected. You may want to try Git Large File Storage - https://git-lfs.github.com. 
remote: error: Trace: eedddea1fcb95663492e16c14fc3a250 
remote: error: See http://git.io/iEPt8g for more information. 
remote: error: File doc/image.eps is 591.70 MB; this exceeds GitHub's file size limit of 100.00 MB 
To https://github.com/traildreaming/myrepo.git 
! [remote rejected] master -> master (pre-receive hook declined) 
error: failed to push some refs to 'https://github.com/traildreaming/myrepo.git' 

未遂#2 試過https://rtyley.github.io/bfg-repo-cleaner/的說明

但它沒有看到我的大文件阻止我進行推送:

$ git的克隆--mirror https://github.com/traildreaming/myrepo.git

Cloning into bare repository 'myrepo.git'... 
Username for 'https://github.com': 
Password for 'https://[email protected]': 
remote: Counting objects: 20471, done. 
remote: Total 20471 (delta 0), reused 0 (delta 0), pack-reused 20471 
Receiving objects: 100% (20471/20471), 812.92 MiB | 4.00 MiB/s, done. 
Resolving deltas: 100% (14464/14464), done. 
Checking connectivity... done. 

$ CP -fr myrepo.git myrepo.git.bac

[email protected] /cygdrive/c/Users/note2/Data/git/tmpmirror 
$ java -jar ../bfg-1.12.12.jar --strip-blobs-bigger-than 100M myrepo.git 

Using repo : C:\Users\note2\Data\git\tmpmirror\myrepo.git 

Scanning packfile for large blobs: 20471 
Scanning packfile for large blobs completed in 103 ms. 
Warning : no large blobs matching criteria found in packfiles - does the repo need to be packed? 
Please specify tasks for The BFG : 
bfg 1.12.12 

ATTTEMPT#3 嘗試這導致「遠程:錯誤:」消息:

$ git的克隆--mirror ../../myrepo/.git

Cloning into bare repository 'myrepo.git'... 
done. 

$ Java的罐子BFG-1.12.12.jar --strip-斑點,降幅高於100M tmpmirror/myrepo/myrepo.git

Using repo : C:\Users\note2\Data\git\tmpmirror\myrepo\myrepo.git 

Scanning packfile for large blobs: 12545 
Scanning packfile for large blobs completed in 66 ms. 
Found 1 blob ids for large blobs - biggest=620441479 smallest=620441479 
Total size (unpacked)=620441479 
Found 1322 objects to protect 
Found 4 commit-pointing refs : HEAD, refs/heads/master, refs/remotes/origin/HEAD, refs/remotes/origin/master 

Protected commits 
----------------- 

These are your protected commits, and so their contents will NOT be altered: 

* commit b68c0cbc (protected by 'HEAD') 

Cleaning 
-------- 

Found 2769 commits 
Cleaning commits:  100% (2769/2769) 
Cleaning commits completed in 1,485 ms. 

Updating 1 Ref 
-------------- 

     Ref     Before  After 
     --------------------------------------- 
     refs/heads/master | b68c0cbc | 49823acc 

Updating references: 100% (1/1) 
...Ref update completed in 18 ms. 

Commit Tree-Dirt History 
------------------------ 

     Earliest            Latest 
     |               | 
     ...........................................................D 

     D = dirty commits (file tree fixed) 
     m = modified commits (commit message or parents changed) 
     . = clean commits (no changes to file tree) 

           Before  After 
     ------------------------------------------- 
     First modified commit | 0ef7f866 | e3d74aee 
     Last dirty commit  | 338d2b46 | 01ca7b80 

Deleted files 
------------- 

     Filename      Git id 
     ------------------------------------------------ 
     image.eps | e12fe50b (591.7 MB) 


In total, 50 object ids were changed. Full details are logged here: 

     C:\Users\note2\Data\git\tmpmirror\myrepo\myrepo.git.bfg-report\2016-06-11\15-59-30 

BFG run is complete! When ready, run: git reflog expire --expire=now --all && git gc --prune=now --aggressive 

$ git的引用日誌到期--expire =現在--all & &混帳GC --prune =現在--aggressive

Counting objects: 20681, done. 
Delta compression using up to 4 threads. 
Compressing objects: 100% (20114/20114), done. 
Writing objects: 100% (20681/20681), done. 
Total 20681 (delta 14625), reused 3226 (delta 0) 
Removing duplicate objects: 100% (256/256), done. 

$混帳推

Counting objects: 210, done. 
Delta compression using up to 4 threads. 
Compressing objects: 100% (82/82), done. 
Writing objects: 100% (210/210), 1.81 MiB | 0 bytes/s, done. 
Total 210 (delta 147), reused 185 (delta 124) 
remote: error: refusing to update checked out branch: refs/heads/master 
remote: error: By default, updating the current branch in a non-bare repository 
remote: error: is denied, because it will make the index and work tree inconsistent 
remote: error: with what you pushed, and will require 'git reset --hard' to match 
remote: error: the work tree to HEAD. 
remote: error: 
remote: error: You can set 'receive.denyCurrentBranch' configuration variable to 
remote: error: 'ignore' or 'warn' in the remote repository to allow pushing into 
remote: error: its current branch; however, this is not recommended unless you 
remote: error: arranged to update its work tree to match what you pushed in some 
remote: error: other way. 
remote: error: 
remote: error: To squelch this message and still keep the default behaviour, set 
remote: error: 'receive.denyCurrentBranch' configuration variable to 'refuse'. 
To /cygdrive/c/Users/note2/Data/git/tmpmirror/myrepo/../../myrepo/.git 
! [remote rejected] master -> master (branch is currently checked out) 
error: failed to push some refs to '/cygdrive/c/Users/note2/Data/git/tmpmirror/myrepo/../../myrepo/.git' 
+0

我認爲它現在正在工作。我不應該停止在「嘗試#3」在「git push」,我嘗試了什麼建議在stackoverflow答案我鏈接到哪個是:「git push https://github.com/traildreaming/myrepo」,而不是「git push」。然後我去了一個空目錄並克隆我的回購。在另一個答案的人說,事情失蹤了。我不確定是否還有事。乍一看看起來沒問題。如果沒有,將會更新瓦特/細節。 – TrailDreaming

回答

0

這裏是我得到了它的「混帳推」工作後,被困由於添加和犯下一個大文件,然後與其他工作的持續承諾,而遠離互聯網:

我下載BFG *罐子來自:
https://rtyley.github.io/bfg-repo-cleaner/

cd tmpmirror; mkdir myrepo; cd myrepo; git clone --mirror ../../myrepo/.git 
java -jar bfg-1.12.12.jar --strip-blobs-bigger-than 100M myrepo.git 
cd myrepo.git; git reflog expire --expire=now --all && git gc --prune=now --aggressive 
git push https://github.com/traildreaming/myrepo 
cd ../../.. 
mv myrepo myrepo_old 
git clone https://github.com/traildreaming/myrepo 
cd myrepo 

如果您收到此消息,然後用額外的步驟嘗試使用下面

$ java -jar ../../bfg-1.12.13.jar --strip-blobs-bigger-than 100M myrepo.git 

Using repo : [DIR]\tmpmirror\myrepo\myrepo.git 

Scanning packfile for large blobs: 20681 
Scanning packfile for large blobs completed in 135 ms. 
Warning : no large blobs matching criteria found in packfiles - does the   repo need to be packed? 
Please specify tasks for The BFG : 
bfg 1.12.13 
Usage: bfg [options] [<repo>] 

    -b <size> | --strip-blobs-bigger-than <size> 
     strip blobs bigger than X (eg '128K', '1M', etc) 

```

cd tmpmirror; mkdir myrepo; cd myrepo; git clone --mirror ../../myrepo/.git 
cd myrepo.git; git repack; cd .. 
java -jar bfg-1.12.12.jar --strip-blobs-bigger-than 100M myrepo.git 
cd myrepo.git; git reflog expire --expire=now --all && git gc --prune=now --aggressive 
git push https://github.com/traildreaming/myrepo 
cd ../../.. 
mv myrepo myrepo_old 
git clone https://github.com/traildreaming/myrepo 
cd myrepo 

然後繼續在新克隆的回購中工作。感謝Am I supposed to run BFG on the mirrored repo or the original?的建議,使用「git push https://github.com/traildreaming/myrepo」而不是「git push」。

1

即使你已刪除在最新的文件提交你仍然有它的一個副本中你的歷史。我想你會想完全從git中刪除它。

你可能想重新設計它。要了解,當你介紹了吧,你可以這樣做:

git log --reverse -n1 doc/image.eps 

然後複製它給你的SHA,做一個互動變基:

git rebase -i sha~1 

保持~1在上面的命令,但更換sha與早期命令輸出中的實際SHA進行比較。如果上述命令不工作,你可能需要設置一個EDITOR,例如:

EDITOR=vim git rebase -i sha~1 

替換vim與你舒服(emacsnano等)的任何命令行編輯器。您可以使用它來使用像​​這樣的GUI編輯器,但是您可能需要傳入其他參數才能強制該過程等待,直至關閉窗口。如果您使用​​你可以運行:

EDITOR="atom --wait" git rebase -i sha~1 

這是要帶你回來的路上的時間。第一行將有pick。您需要將其更改爲edit。然後保存並退出編輯器。不要更改任何其他pick s。

這會讓你回到引入大文件的提交。這樣下去一直到完成

git rebase --continue 

,那麼你就大功告成了:現在,您可以從混帳刪除:

git rm doc/image.eps && git commit --amend 

然後繼續重訂。你應該能夠git push。但是,如果沒有,那麼您可能在稍後的提交中更新了映像。你會想要做同樣的git rm doc/image.eps && git commit --amend && git rebase --continue,我們在每次停止時做過。

我假設了很多事情,所以我希望你對git,編輯器和命令行使用這些信息感到滿意。

P.S.這樣做可能會更短,更簡潔,但是因爲你問這個問題,我假設你不需要一個神奇的git命令,它可以通過你自己的歷史來摧毀你的歷史。首先,讓我們一步一步地嘗試。

相關問題