如何删除前N个提交并保留其余的提交不变?
换句话说,我想在第n个提交点拆分仓库,选择从第n+1个提交开始的提交,并丢弃从第1个到第n个的提交。
我不知道如何实现这一点。只尝试过git rebase,但它没有起作用。
以下是我使用git rebase所做的操作。
例如,用于测试的存储库为https://github.com/danistefanovic/build-your-own-x.git。
更新
与 移除/切断Git的修订/提交历史 重复。
但没有找到保留时间戳的方法。
换句话说,我想在第n个提交点拆分仓库,选择从第n+1个提交开始的提交,并丢弃从第1个到第n个的提交。
我不知道如何实现这一点。只尝试过git rebase,但它没有起作用。
以下是我使用git rebase所做的操作。
例如,用于测试的存储库为https://github.com/danistefanovic/build-your-own-x.git。
Run
git rebase -i --root
Mark the first 20 commits as deleted
d 4b6d12e Initial commit d f81138e Add links to issue form d 3530d91 Update README.md d 506b834 Update README.md d 79f41aa Update README.md d f9f9113 Update README.md d 9c8f134 Add resource type d 133469b Update ISSUE_TEMPLATE d 3a47f54 Add tutorials #1 d 0271577 Add tutorial #2 d 525953b Add tutorial #3 d 2796fe5 Update ISSUE_TEMPLATE d 4f58667 Updated wrong link language from Go to Node.js d 0c525a7 Add tutorial #5 d 0484fca Add OS: Build a minimal multi-tasking kernel for ARM d 457d5bb Add tutorial #9 d 41ba7fc Add tutorial d dfbbf0f Add tutorial #11 d b76dad5 Add tutorial #12 d cd3bd26 Add tutorial #13 pick c5f6c94 readme: Add my tutorial on shell pick 1f3c285 Add a minimal interpreter, compiler (x86/Arm) and JIT compiler ...
No luck. I have to handle conflicts manually as show blow.
$ git rebase -i --root error: could not apply c5f6c94... readme: Add my tutorial on shell Resolve all conflicts manually, mark them as resolved with "git add/rm <conflicted_files>", then run "git rebase --continue". You can instead skip this commit: run "git rebase --skip". To abort and get back to the state before "git rebase", run "git rebase --abort". Could not apply c5f6c94859d852797c26d815e438e6a697c137a9... readme: Add my tutorial on shell
更新
与 移除/切断Git的修订/提交历史 重复。
但没有找到保留时间戳的方法。