作者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/cn.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