Here are my commits:
A B C
With C being the current commit. I want things to look like this on origin:
A B C A
So A is my current commit, but B and C are retained. I currently have the repo cloned with C being the current commit. What do I need to do next to get origin how I want it?
Commits ‘B’ and ‘C’ are progressive states of the branch’s history. To reset to ‘A’ without losing ‘B’ or ‘C’ locally, just use a new branch on origin:
‘B’ and ‘C’ will be retained on ‘master’, so you can
git cherry-pick <commit_of_B_or_C>orgit merge masterwithout trouble.If you really want ‘B’ and C’, but want to reset ‘master’ to ‘A’, and have thought through the consequences of forcibly overwriting your remote:
That’ll save ‘B’ and ‘C’ locally on the ‘archived-master’ branch.
I would avoid
git revertfor this. Revert commits make commands likegit bisectandgit rebasemore difficult, and if you ever want to reuse ‘B’ and ‘C’ it’s harder for a human to parse the history.