Question:
I want to rollback to a previous commit, and then publish that code, then go back to the latest commit.
i.e. so my master is pointing to an older commit version just so I can pulish that version, then I want to go back to the latest commit I was one initially.
How can I do this?
Answer:
If you want to do this and revert the master to the previous commit:
1 2 3 4 5 |
git checkout master~1 # Checkout previous commit on master git checkout -b new_master # Create branch for new master git branch -D master # Delete old master git branch -mv new_master master # Make new_master master |
Alternatively:
1 2 |
git reset --hard master~1 # Reset current branch to one commit ago on master |