close
使用GIT一年多 終於遇到了使用GIT LFS的廠景
 
GIT LFS 這個就是針對大檔案 至於怎樣較大檔案 每個附檔名都有它的規則 因此不贅述 有50MB 有100MB的
 
未提供相片說明。
https://github.com/git-lfs/git-lfs/tree/master/docs?utm_source=gitlfs_site&utm_medium=docs_link&utm_campaign=gitlfs

 

git 所有指令表

start a working area (see also: git help tutorial)
   clone      Clone a repository into a new directory
   init       Create an empty Git repository or reinitialize an existing one

work on the current change (see also: git help everyday)
   add        Add file contents to the index
   mv         Move or rename a file, a directory, or a symlink
   reset      Reset current HEAD to the specified state
   rm         Remove files from the working tree and from the index

examine the history and state (see also: git help revisions)
   bisect     Use binary search to find the commit that introduced a bug
   grep       Print lines matching a pattern
   log        Show commit logs
   show       Show various types of objects
   status     Show the working tree status

grow, mark and tweak your common history
   branch     List, create, or delete branches
   checkout   Switch branches or restore working tree files
   commit     Record changes to the repository
   diff       Show changes between commits, commit and working tree, etc
   merge      Join two or more development histories together
   rebase     Reapply commits on top of another base tip
   tag        Create, list, delete or verify a tag object signed with GPG

collaborate (see also: git help workflows)
   fetch      Download objects and refs from another repository
   pull       Fetch from and integrate with another repository or a local branch
   push       Update remote refs along with associated objects

 

git init 
git add "xx" "XX" "xx" //一堆路徑
git commit -a -m "name"
git remote add origin http://URL //GIT 路徑 目前是打到我的GITHUB https://github.com/tm731531
git remote remove origin http://URL //測試刪除路徑

git status //檢查
git remote add origin http://URL //加回來
git push -u origin master // 推上去

GIT 上傳超過50MB的檔案

remote: Resolving deltas: 100% (212/212), done.
remote: warning: File plot/SaveModel/cifarCnnModelnew.h5 is 76.25 MB; this is larger than GitH
ub's recommended maximum file size of 50.00 MB
remote: error: GH001: Large files detected. You may want to try Git Large File Storage - https
://git-lfs.github.com.
remote: error: Trace: fcadde3cb8fc852efd15797c4aa6a87d
remote: error: See http://git.io/iEPt8g for more information.
remote: error: File pydata-book-2nd-edition/datasets/fec/P00000001-ALL.csv is 150.56 MB; this exceeds GitHub's file size limit of 100.00 MB
To https://github.com/tm731531/Python-All.git
 ! [remote rejected] master -> master (pre-receive hook declined)
 
下載git-lfs

 
"路徑">git lfs track "plot/SaveModel/cifarCnnModelnew.h5"
Tracking "plot/SaveModel/cifarCnnModelnew.h5"

"路徑">git lfs track "pydata-book-2nd-edition/datasets"路徑""路徑"/fec/P00000001-ALL.c
sv"
Tracking "pydata-book-2nd-edition/datasets/fec/P00000001-ALL.csv"

"路徑">git add .gitattributes

"路徑">git commit -a -m "add bigfile"
[master 62cbc3d] add bigfile
 3 files changed, 5 insertions(+), 1001732 deletions(-)
 create mode 100644 .gitattributes
 rewrite plot/SaveModel/cifarCnnModelnew.h5 (99%)
 rewrite pydata-book-2nd-edition/datasets/fec/P00000001-ALL.csv (99%)
 
 
 "路徑">git commit -a -m "add bigfile"
[master 62cbc3d] add bigfile
 3 files changed, 5 insertions(+), 1001732 deletions(-)
 create mode 100644 .gitattributes
 rewrite plot/SaveModel/cifarCnnModelnew.h5 (99%)
 rewrite pydata-book-2nd-edition/datasets/fec/P00000001-ALL.csv (99%)

"路徑">git push -u origin master
Git LFS: (2 of 2 files) 226.81 MB / 226.81 MB
Counting objects: 1272, done.
Delta compression using up to 4 threads.
Compressing objects: 100% (1241/1241), done.
Writing objects:  59% (761/1272), 90.97 MiB | 259.00 KiB/s

 

"路徑">git push -u origin master
Git LFS: (0 of 0 files, 2 skipped) 0 B / 0 B, 226.81 MB skipped                                       Counting objects: 1278, done.
Delta compression using up to 4 threads.
Compressing objects: 100% (1247/1247), done.
Writing objects:  59% (765/1278), 102.45 MiB | 249.00 KiBremote: fatal: early EOF
s
error: RPC failed; curl 55 SSL_write() returned SYSCALL, errno = 10053
atal: The remote end hung up unexpectedly MiB | 1024 bytes/s
Writing objects: 100% (1278/1278), 289.73 MiB | 279.00 KiB/s, done.
Total 1278 (delta 220), reused 0 (delta 0)
fatal: The remote end hung up unexpectedly
Everything up-to-date

GIT說明圖來源:
https://blog.techbridge.cc/2018/01/17/learning-programming-and-coding-with-python-git-and-github-tutorial/

上面方法失敗
https://gitbook.tw/chapters/faq/remove-files-from-git.html
原因是 就算把大檔案轉到LFS 但是還是要把紀錄刪掉才可以 所以大檔案寫入了就要想辦法清除
 

 git filter-branch -f --tree-filter "rm -f config/database.yml"
 git reflog expire --all --expire=now
 git fsck --unreachable
 git gc --prune=now
 git reset 27f6ed6 --hard

主要方法就是強力覆蓋後 透過定過期日 就把之前的過期調 下一步透過GC把它清除

官方說明

https://help.github.com/articles/working-with-large-files/
上傳前

 

上傳後

arrow
arrow
    文章標籤
    git git-lfs
    全站熱搜

    丁滿 發表在 痞客邦 留言(0) 人氣()