Somehow, I've ended up with a project structure as such:
> 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
I have tried everything (reset --hard
, cherry-pick
, rebase -i, drop
, etc) to remove commits e5753c5
to 32aedba
, which have mistakenly appeared as duplicates of the 4 commits after while I was rushing part of the project for a deadline :)
What command can I perform to achieve the following output:
> 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
Example before and after of what I've tried:
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
First of all, a stale branch is doing no harm, so your goal is unclear to me. Is it only presentation? If yes, you could output only master
with
git log --graph --oneline master
But let's accept the premise : how to get rid of the unwanted commits?
You'd have to find which references are on commit 32aedba
with something along the lines of
git branch --contains 32aedba
then delete these branches with
git branch -D <branch>
(-D
rather than -d
because it will be unmerged and will require force)
An alternative (see Lasse's comment) would be to output refs in your command with
git log --graph --oneline --all --decorate