Reputation: 47
I want to delete older commit, because I had to separate it to 2 commits.
So changes, that are at a5b4cd
are same like changes in 2a0d40e
+ a8bb836
.
2a0d40e Add sending
a8bb836 Add parsing
a5b4cbd Add sending and parsing <--- I want to delete this
f6063ac First commit
I tried some git rebase -i
and fixup
here, but everytime, it will add changes from this "deleted" commit to another commit and that I dont want.
Upvotes: 2
Views: 229
Reputation: 1326776
Don't use fixup. Simply remove that line during your interactive rebase.
That will be enough for that commit to be dropped.
But then be prepared to have to force push (git push --force
) which can be problematic on public branches.
Another option would be git revert
(if you just want to cancel that commit rather than remove it from the history completely)
Before rebasing when I wanted to separate them I got Commit2 with File3 and File4. Then I wanted to separate it, so I have deleted File4, add Commit3 (just with File1 and File3), then added File4 and make Commit4.
Then the solution is different: While at Commit 4 (with all your files), do a
git reset --soft Commit1
git add File3
git commit -m "Add File3"
git add File4
git commit -m "Add File4"
Upvotes: 2