I have the following commit history (everything is pushed) where I want to discard all commits in the marked spot e.g all commits from (and including) e603105 and forward.

You can hard reset back
git reset --hard ff61726
This is considered re-writing history so then it would require a force push
git push -f
You cannot directly delete commits from git, but you can stop a branch pointing at them, and they will eventually be deleted by a "garbage collection" routine.
To move a branch pointer, you can use git reset.
Specifically, if "some-branch" currently points at ac033d7, and you run this:
git checkout some-branch
git reset --hard ff61726
Now "some-branch" points at commit ff61726, but commit ac033d7 still exists, and will only be garbage collected once nothing points to it any more.
One of the things that will probably still point to it is any remote copy of the "some-branch" branch, e.g. on Github/BitBucket/GitLab. To move that branch, you need to perform a "force push":
git push --force-with-lease
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With