I'm still not clear where the repo is. You say it's bare but you must have a non-bare somewhere too.
If you just want to rewind local branches then you want to use git reset
. So if you have a local branch beta
then you can rewind it like this:
$ git checkout beta
$ git reset --hard HEAD~2
This will drop 3 commits: HEAD
, HEAD~1
and HEAD~2
. These will get garbage collected in about 90 days so you can get them back if needed.
If you have a remote repo named origin
(that is bare) and you'd like to rewind the branch over there, then you can do this via a forced push. Let's say you pushed 3 commits on beta
before they're ready. You can keep them in your local project but remove them from the remote bare repo like this:
$ git push -f origin beta~3:beta
This can be harsh to others using that repository but it sounds like you're okay with that.
If you only have a bare repo then you can forcibly reset the branch like so:
$ git branch -f beta beta~3
Note: this also works for the first case of rewinding local branches. Again, this is unfriendly to anyone using this repo.