You can use
git reset --hard <commit_id>
to reset the branch pointer to the specified commit and also reset the working directory. If the old commits had been pushed to your remote, you will have to do a force push to push the reset versions.
git push -f
It is possible that your remote may be configured to reject force pushes.
You will lose all the code changes in commits that you've reset, so be sure. If you wanted to retain your ability to access them just in case, you could create a separate branch to point to them before reseting.
Deleting a branch and recreating it is also valid - a branch is just a pointer to a commit, so this will have exactly the same effect with all the same possible concerns.
The initial commit was from another repo that I had imported, and I needed to just reset the repo without the old history without recreating it in BitBucket, so I init'd a new repo in another folder, copied .git to the folder, deleted all the files but the .gitignore, made an initial commit (before setting the remote), then added the remote and force-pushed, and it worked, though it some minutes for BitBucket to completely recognize it.
This community is celebrating its one-year anniversary and Atlassian co-founder Mike Cannon-Brookes has all the feels.Read more
It's Monday morning here is sunny California! (86 degrees in April, what is happening right now??) Time for another Miscellaneous Monday! I was having a random conversation with my nine-year-old thi...
Connect with like-minded Atlassian users at free events near you!Find a group
Connect with like-minded Atlassian users at free events near you!
Unfortunately there are no AUG chapters near you at the moment.Start an AUG
You're one step closer to meeting fellow Atlassian users at your local meet up. Learn more about AUGs