Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
如何从历史记录中删除第一个 git commit?我只想让树从第二次提交开始。我知道git rebase -i <sha1_of_commit>,但这不适用于第一次提交。
git rebase -i <sha1_of_commit>
存储库不与任何人共享。
如果你还没有发布你的 repo,你可以使用git filter-branch. 请记住,从技术上讲,这会创建新的存储库,与旧的存储库无关(因此是“如果你还没有发布它”规则)。
git filter-branch
git filter-branch --commit-filter ' if [ "$GIT_COMMIT" = "full ID/SHA of the commit you want to skip here" ]; then skip_commit "$@"; else git commit-tree "$@"; fi' HEAD