作者yshihyu (yshihyu)
看板Linux
標題[問題] git log 保留部份最新
時間Sun Sep 3 01:28:29 2017
我從有從github 抓了一包程式 , 發現 .git 太大
我想把保留最新的20筆 git commit 資料
請問要怎麼做才可以只保留最新20筆
抱歉我講一下我推到bitbucket 步驟
1. git clone
https://github.com/xxxx/xxxx.git --depth 20
2. git remote add backup ssh://
[email protected]/nameID/backup.git
3. git push -u backup master
push 之後就出現下面訊息
! [remote rejected]master -> master (shallow up not allowed)
謝謝
--
※ 發信站: 批踢踢實業坊(ptt.cc), 來自: 175.181.154.191
※ 文章網址: https://webptt.com/m.aspx?n=bbs/Linux/M.1504373313.A.BA5.html
1F:推 Bencrie: git clone --depth 20 09/03 01:48
2F:→ yshihyu: 這方法我測試過確實可以!但是我遇到我想把這包程式 09/03 10:19
3F:→ yshihyu: 裡面的20筆commit 資料推到另外一個 repo 會失敗... 09/03 10:20
4F:→ yshihyu: 錯誤訊息印象中是提到沒有是git log 不完整 09/03 10:21
5F:推 Bencrie: 那你還是 pull unswallow 整個拉下來吧 09/03 13:03
6F:→ Bencrie: 沒人知道你那 20 commits 樹枝是怎麼長的 09/03 13:04
7F:→ yshihyu: ! [remote rejected]master -> master (shallow update 09/03 17:33
8F:→ yshihyu: not allowed) 09/03 17:33
9F:→ yshihyu: git fetch --unshallow origin <-- 網路上說這樣解決 09/03 17:35
10F:→ yshihyu: 可是我這樣做看起來又把所有 commit 都pull 下來 09/03 17:35
11F:→ danny8376: 就是要全pull下來 你沒完整tree怎知道你要push到哪 09/04 00:56
12F:→ yshihyu: 那有辦法針對最新20筆 commit 重建tree 嘛? 09/04 11:22
13F:推 Vett: 我有時間研究這個我會直接把整個tree拉下來 09/04 16:15
14F:推 Bencrie: 原 po 也沒說是怎麼推的。merge/rebase 還是 cherry-pick 09/04 17:37
※ 編輯: yshihyu (175.181.254.216), 09/05/2017 00:55:44
※ 編輯: yshihyu (175.181.254.216), 09/05/2017 00:56:22
15F:推 Bencrie: 你 backup 那個也 checkout 成 local branch 再 merge 09/05 02:05
16F:→ Bencrie: 不然就土法煉鋼 git format-patch -20 & git am XD 09/05 02:05
17F:→ soem: 試了一下,似乎可以用commit-tree合併重建21個commit以前, 09/07 01:38
18F:→ soem: 然後用cherry-pick -m 1拉剩下的20個commit 09/07 01:38