Is there a way to remove all commits before a specified commit and use that commit as the initial?
The more easier solution would be, Consider originally your branch has commit main and you did a commit first, now you also did a commit second on top of first. So you have something like:
main->first->second
Now you want to have second on top of main rather than on top of first. Something like:
main->second->first or main->second
You can simply do,
git rebase -i main
This will give you an interactive shell where you can rearrange the order of commits or remove any commit of your choice.