不知怎么的,我最终得到了这样的项目结构:
> git log --graph --oneline --all
* a72aed6 (master) feat(data:model:user): modified db service
* 099becd feat(data:model:user): added CRUD for user model
* 59ac87d refactor(): separating concerns
* dfb983f chore(data:api): removed graphql testing cruft
* aa92817 feat(data:db): setup pg pool connection and query in db/index.ts
* ee03d48 feat(wf): added express
* 184cef0 feat(data:db): added pg
| * 32aedba chore(data:api): removed graphql testing cruft
| * a6825d2 feat(data:db): setup pg pool connection and query in db/index.ts
| * 4a901b1 feat(wf): added express
| * e5753c5 feat(data:db): added pg
|/
* 94426bc (HEAD) feat(qc:test:jest): added test coverage script
* 6126689 feat(build:deploy): added webpack typescript integrations
* 172da85 feat(build:deploy): added webpack-cli
* bab6afa feat(qc): added husky
* c570f33 feat(vcs): added git
我已经尝试了一切(reset --hard
、cherry-pick
、rebase -i, drop
等(来删除提交e5753c5
到32aedba
,这些提交错误地显示为4个提交的副本,而我正赶在最后期限前完成项目的一部分:(
我可以执行什么命令来实现以下输出:
> git log --graph --oneline --all
* a72aed6 (master) feat(data:model:user): modified db service
* 099becd feat(data:model:user): added CRUD for user model
* 59ac87d refactor(): separating concerns
* dfb983f chore(data:api): removed graphql testing cruft
* aa92817 feat(data:db): setup pg pool connection and query in db/index.ts
* ee03d48 feat(wf): added express
* 184cef0 feat(data:db): added pg
* 94426bc feat(qc:test:jest): added test coverage script
* 6126689 feat(build:deploy): added webpack typescript integrations
* 172da85 feat(build:deploy): added webpack-cli
* bab6afa feat(qc): added husky
* c570f33 feat(vcs): added git
我尝试过的前后示例:
git checkout 32aedba
git rebase -i 94426bc
# `drop` to the above commits
git log --graph --oneline --all
# Returns as above, with HEAD at 94426bc
git checkout 32aedba
git reset --hard HEAD~4
# `drop` to the above commits
git log --graph --oneline --all
# Returns as above, with HEAD at 94426bc
首先,一个过时的分支不会造成任何伤害,所以我不清楚你的目标。这只是演示吗?如果是,则只能输出带有的master
git log --graph --oneline master
但让我们接受一个前提:如何消除不需要的提交?
你必须找到哪些引用在提交32aedba
时与类似
git branch --contains 32aedba
然后用删除这些分支
git branch -D <branch>
(-D
而不是-d
,因为它将不合并并且需要强制(
另一种选择(参见Lasse的评论(是用输出命令中的refs
git log --graph --oneline --all --decorate
git push origin--delete[branchName]删除远程分支