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
If you want to avoid force pushing, here's how to revert your repo to an older commit and preserve all intervening work:
git checkout 307a5cd # check out the commit that you want to reset to
git checkout -b fixy # create a branch named fixy to do the work
git merge -s ours master # merge master's history without changing any files
git checkout master # switch back to master
git merge fixy # and merge in the fixed branch
git push # done, no need to force push!
Done! Replace 307a5cd with whatever commit you want in your repo.
(I know the first two lines can be combined, but I think that makes it less clear what's going on)
Here it is graphically:
c1 -- c2 -- c3 -- c4 -- c2' -- c5 ...
\ /
'------------'
You effectively remove c3 and c4 and set your project back to c2. However, c3 and c4 are still available in your project's history if you ever want to see them again.